From c8a59c1c10d1c936bf65d81144e096d98d7a053a Mon Sep 17 00:00:00 2001 From: joey Date: Sun, 26 Nov 2006 20:05:57 +0000 Subject: [PATCH] * Git backend improvements, including bug fixes and better robustness. --- IkiWiki/Rcs/git.pm | 43 +++++++++++++++++++++++-------------------- debian/changelog | 9 ++++++--- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm index 05eaa8d78..ce2384897 100644 --- a/IkiWiki/Rcs/git.pm +++ b/IkiWiki/Rcs/git.pm @@ -153,14 +153,15 @@ sub _parse_diff_tree (@) { #{{{ my ($dt_ref) = @_; # End of stream? - return if !defined @{ $dt_ref } || !length @{ $dt_ref }[0]; + return if !defined @{ $dt_ref } || + !defined @{ $dt_ref }[0] || !length @{ $dt_ref }[0]; my %ci; # Header line. HEADER: while (my $line = shift @{ $dt_ref }) { return if $line !~ m/^(.+) ($sha1_pattern)/; - my $sha1 = $1; + my $sha1 = $2; $ci{'sha1'} = $sha1; last HEADER; } @@ -195,10 +196,10 @@ sub _parse_diff_tree (@) { #{{{ } } - error("No 'tree' or 'parents' seen in diff-tree output") + debug("No 'tree' or 'parents' seen in diff-tree output") if !defined $ci{'tree'} || !defined $ci{'parents'}; - $ci{'parent'} = @{ $ci{'parents'} }[0]; + $ci{'parent'} = @{ $ci{'parents'} }[0] if defined $ci{'parents'}; # Commit message. COMMENT: while (my $line = shift @{ $dt_ref }) { @@ -239,14 +240,14 @@ sub _parse_diff_tree (@) { #{{{ last FILE; } - warn "No detail in diff-tree output" if !defined $ci{'details'}; + debug("No detail in diff-tree output") if !defined $ci{'details'}; return \%ci; } #}}} -sub git_commit_info (;$$) { #{{{ +sub git_commit_info ($;$) { #{{{ # Return an array of commit info hashes of num commits (default: 1) - # starting from the given sha1sum (default: HEAD). + # starting from the given sha1sum. my ($sha1, $num) = @_; @@ -254,7 +255,7 @@ sub git_commit_info (;$$) { #{{{ my @raw_lines = run_or_die(qq{git-rev-list --max-count=$num $sha1 | - git-diff-tree --stdin --pretty=raw -M -r}); + git-diff-tree --stdin --pretty=raw --always -M -m -r}); my @ci; while (my $parsed = _parse_diff_tree(\@raw_lines)) { @@ -352,17 +353,19 @@ sub rcs_recentchanges ($) { #{{{ eval q{use Date::Parse}; error($@) if $@; - my ($sha1, $type, $when, $diffurl, $user, @pages, @message, @rets); + my @rets; INFO: foreach my $ci (git_commit_info('HEAD', $num)) { my $title = @{ $ci->{'comment'} }[0]; # Skip redundant commits. next INFO if ($title eq $dummy_commit_msg); - $sha1 = $ci->{'sha1'}; - $type = "web"; - $when = time - $ci->{'author_epoch'}; + my ($sha1, $when) = ( + $ci->{'sha1'}, + time - $ci->{'author_epoch'} + ); + my (@pages, @messages); DETAIL: foreach my $detail (@{ $ci->{'details'} }) { my $diffurl = $config{'diffurl'}; my $file = $detail->{'file'}; @@ -377,13 +380,14 @@ sub rcs_recentchanges ($) { #{{{ diffurl => $diffurl, }; } + push @messages, { line => $title }; - push @message, { line => $title }; + my ($user, $type) = (q{}, "web"); - if (defined $message[0] && - $message[0]->{line} =~ m/$config{web_commit_regexp}/) { + if (defined $messages[0] && + $messages[0]->{line} =~ m/$config{web_commit_regexp}/) { $user=defined $2 ? "$2" : "$3"; - $message[0]->{line}=$4; + $messages[0]->{line}=$4; } else { $type ="git"; $user = $ci->{'author_username'}; @@ -394,12 +398,11 @@ sub rcs_recentchanges ($) { #{{{ user => $user, committype => $type, when => $when, - message => [@message], + message => [@messages], pages => [@pages], - } if @pages; + }; - $sha1 = $type = $when = $diffurl = $user = undef; - @pages = @message = (); + last INFO if @rets >= $num; } return @rets; diff --git a/debian/changelog b/debian/changelog index 8d6c7851b..0429f152d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ ikiwiki (1.34) UNRELEASED; urgency=low * Make the openid plugin support the callbacks from myopenid.com via its affiliate program. * Add toggle plugin. + * Add a poll plugin. + * Add quick mode for archive page generation. * Introduce the goodstuff bundle. This is a kind of plugin, that just enables many other plugins. It's an easy way to boost ikiwiki from its default, basic wiki, to a full-featured wiki, without manually picking the right @@ -44,9 +46,10 @@ ikiwiki (1.34) UNRELEASED; urgency=low and their IP address, and needs to construct its own commit message containing them, or do something more appropriate for the given RCS. * Add softwaresite example. - * Add a poll plugin. - * Add quick mode for archive page generation. - * Mercurial backend improvements, including --get-ctime support. + * Mercurial backend improvements, including --get-ctime support. (Emanuele + Aina) + * Git backend improvements, including bug fixes and better robustness. + (Recai Oktaş) -- Joey Hess Sun, 26 Nov 2006 15:01:14 -0500 -- 2.45.0