]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/git.pm
only_committed_changes could fail in a git repository merged with git merge -s ours.
[ikiwiki.git] / IkiWiki / Plugin / git.pm
index f2b5f9ef98099e99f8adf23be3e19c7efbfb7468..75b89e476bbb4bf1da262385a8e390994489f0e9 100644 (file)
@@ -467,6 +467,11 @@ sub git_commit_info ($;$) {
 sub rcs_find_changes ($) {
        my $oldrev=shift;
 
+       # Note that git log will sometimes show files being added that
+       # don't exist. Particularly, git merge -s ours can result in a
+       # merge commit where some files were not really added.
+       # This is why the code below verifies that the files really
+       # exist.
        my @raw_lines = run_or_die('git', 'log',
                '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
                '--no-renames', , '--reverse',
@@ -476,18 +481,22 @@ sub rcs_find_changes ($) {
        my %changed;
        my %deleted;
        my $nullsha = 0 x 40;
-       my $newrev;
+       my $newrev=$oldrev;
        while (my $ci = parse_diff_tree(\@raw_lines)) {
                $newrev=$ci->{sha1};
                foreach my $i (@{$ci->{details}}) {
                        my $file=$i->{file};
                        if ($i->{sha1_to} eq $nullsha) {
-                               delete $changed{$file};
-                               $deleted{$file}=1;
+                               if (! -e "$config{srcdir}/$file") {
+                                       delete $changed{$file};
+                                       $deleted{$file}=1;
+                               }
                        }
                        else {
-                               delete $deleted{$file};
-                               $changed{$file}=1;
+                               if (-e "$config{srcdir}/$file") {
+                                       delete $deleted{$file};
+                                       $changed{$file}=1;
+                               }
                        }
                }
        }
@@ -609,7 +618,7 @@ sub rcs_commit_helper (@) {
        # So we should ignore its exit status (hence run_or_non).
        if (run_or_non('git', 'commit', '-m', $params{message}, '-q', @opts)) {
                if (length $config{gitorigin_branch}) {
-                       run_or_cry('git', 'push', $config{gitorigin_branch});
+                       run_or_cry('git', 'push', $config{gitorigin_branch}, $config{gitmaster_branch});
                }
        }
        
@@ -660,7 +669,9 @@ sub rcs_recentchanges ($) {
                my @pages;
                foreach my $detail (@{ $ci->{'details'} }) {
                        my $file = $detail->{'file'};
-                       my $efile = uri_escape_utf8($file);
+                       my $efile = join('/',
+                               map { uri_escape_utf8($_) } split('/', $file)
+                       );
 
                        my $diffurl = defined $config{'diffurl'} ? $config{'diffurl'} : "";
                        $diffurl =~ s/\[\[file\]\]/$efile/go;