]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Rcs/git.pm
* If gitorigin_branch is set to the empty string, don't push or pull.
[git.ikiwiki.info.git] / IkiWiki / Rcs / git.pm
index 9f64b8630dce9c6f8d4f6c08de51ad551fc24c51..c436deb4da0ab7334ac087ca318ac41b2847fa72 100644 (file)
@@ -23,8 +23,6 @@ sub _safe_git (&@) { #{{{
 
        if (!$pid) {
                # In child.
-               open STDERR, ">&STDOUT"
-                   or error("Cannot dup STDOUT: $!");
                # Git commands want to be in wc.
                chdir $config{srcdir}
                    or error("Cannot chdir to $config{srcdir}: $!");
@@ -40,7 +38,7 @@ sub _safe_git (&@) { #{{{
 
        close $OUT;
 
-       ($error_handler || sub { })->("'@cmdline' failed: $!") if $?;
+       $error_handler->("'@cmdline' failed: $!") if $? && $error_handler;
 
        return wantarray ? @lines : ($? == 0);
 }
@@ -182,7 +180,7 @@ sub _parse_diff_tree ($@) { #{{{
                        $ci{ "${who}_epoch" } = $epoch;
                        $ci{ "${who}_tz"    } = $tz;
 
-                       if ($name =~ m/^([^<]+) <([^@]+)/) {
+                       if ($name =~ m/^([^<]+) <([^@>]+)/) {
                                my ($fullname, $username) = ($1, $2);
                                $ci{"${who}_fullname"}    = $fullname;
                                $ci{"${who}_username"}    = $username;
@@ -256,8 +254,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;
@@ -286,7 +285,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 ($) { #{{{
@@ -336,7 +337,9 @@ sub rcs_commit ($$$;$$) { #{{{
        $message = possibly_foolish_untaint($message);
        if (run_or_non('git-commit', '-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
@@ -372,9 +375,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;
@@ -460,14 +463,14 @@ sub rcs_notify () { #{{{
 } #}}}
 
 sub rcs_getctime ($) { #{{{
-       # Get the ctime of file.
-
-       my ($file) = @_;
+       my $file=shift;
+       # Remove srcdir prefix
+       $file =~ s/^\Q$config{srcdir}\E\/?//;
 
        my $sha1  = git_sha1($file);
        my $ci    = git_commit_info($sha1);
        my $ctime = $ci->{'author_epoch'};
-       debug("ctime for '$file': ". localtime($ctime) . "\n");
+       debug("ctime for '$file': ". localtime($ctime));
 
        return $ctime;
 } #}}}