]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Rcs/git.pm
Merge branch 'master' of ssh://git.kitenet.net/srv/git/ikiwiki.info
[ikiwiki.git] / IkiWiki / Rcs / git.pm
index 3407354c9a28a5e9ccbe4f313ade0f4dd40ed6b2..b5562f0edd236c9674ebca35368bf3b512a7cddc 100644 (file)
@@ -165,7 +165,10 @@ sub _parse_diff_tree ($@) { #{{{
        # Identification lines for the commit.
        while (my $line = shift @{ $dt_ref }) {
                # Regexps are semi-stolen from gitweb.cgi.
-               if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
+               if ($line =~ m/^commit ([0-9a-fA-F]{40})$/) {
+                       $ci{'commit'} = $1;
+               }
+               elsif ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
                        $ci{'tree'} = $1;
                }
                elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
@@ -254,8 +257,9 @@ sub git_commit_info ($;$) { #{{{
 
        $num ||= 1;
 
-       my @raw_lines =
-           run_or_die('git-log', "--max-count=$num", '--pretty=raw', '--raw', '--abbrev=40', '--always', '-m', '-r', $sha1, '--', '.');
+       my @raw_lines = run_or_die('git-log', "--max-count=$num", 
+               '--pretty=raw', '--raw', '--abbrev=40', '--always', '-m',
+               '-r', $sha1, '--', '.');
        my ($prefix) = run_or_die('git-rev-parse', '--show-prefix');
 
        my @ci;
@@ -284,7 +288,9 @@ sub git_sha1 (;$) { #{{{
 sub rcs_update () { #{{{
        # Update working directory.
 
-       run_or_cry('git-pull', $config{gitorigin_branch});
+       if (length $config{gitorigin_branch}) {
+               run_or_cry('git-pull', $config{gitorigin_branch});
+       }
 } #}}}
 
 sub rcs_prepedit ($) { #{{{
@@ -332,9 +338,11 @@ sub rcs_commit ($$$;$$) { #{{{
        # git-commit(1) returns non-zero if file has not been really changed.
        # so we should ignore its exit status (hence run_or_non).
        $message = possibly_foolish_untaint($message);
-       if (run_or_non('git-commit', '-m', $message, '-i', $file)) {
+       if (run_or_non('git-commit', '-q', '-m', $message, '-i', $file)) {
                unlockwiki();
-               run_or_cry('git-push', $config{gitorigin_branch});
+               if (length $config{gitorigin_branch}) {
+                       run_or_cry('git-push', $config{gitorigin_branch});
+               }
        }
 
        return undef; # success
@@ -370,9 +378,9 @@ sub rcs_recentchanges ($) { #{{{
 
                my (@pages, @messages);
                foreach my $detail (@{ $ci->{'details'} }) {
-                       my $diffurl = $config{'diffurl'};
-                       my $file    = $detail->{'file'};
+                       my $file = $detail->{'file'};
 
+                       my $diffurl = $config{'diffurl'};
                        $diffurl =~ s/\[\[file\]\]/$file/go;
                        $diffurl =~ s/\[\[sha1_parent\]\]/$ci->{'parent'}/go;
                        $diffurl =~ s/\[\[sha1_from\]\]/$detail->{'sha1_from'}/go;
@@ -426,12 +434,9 @@ sub rcs_notify () { #{{{
        #
        # Here, we rely on a simple fact: we can extract all parts of the
        # notification content by parsing the "HEAD" commit (which also
-       # triggers a refresh of IkiWiki pages) and we can obtain the diff
-       # by comparing HEAD and HEAD^ (the previous commit).
-
-       my $sha1 = 'HEAD'; # the commit which triggers this action
+       # triggers a refresh of IkiWiki pages).
 
-       my $ci = git_commit_info($sha1);
+       my $ci = git_commit_info('HEAD');
        return if !defined $ci;
 
        my @changed_pages = map { $_->{'file'} } @{ $ci->{'details'} };
@@ -446,6 +451,8 @@ sub rcs_notify () { #{{{
                $message = join "\n", @{ $ci->{'comment'} };
        }
 
+       my $sha1 = $ci->{'commit'};
+
        require IkiWiki::UserInfo;
        send_commit_mails(
                sub {