From: Simon McVittie Date: Wed, 11 Jan 2017 19:28:48 +0000 (+0000) Subject: Update git plugin to version 3.20141016.3 (Debian jessie) X-Git-Tag: debian/3.20120629.2+deb7u2~39 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/258a9e1e1bd50968cbd53349fc3bea0e9b1d4e05 Update git plugin to version 3.20141016.3 (Debian jessie) This adds some new hooks that are never actually called in this version, but that's harmless. commit 59cfb9b6d0f5f60516d17c79365318711a92fb04 Author: Joey Hess Date: 2014-04-05 19:09:05 -0400 only_committed_changes could fail in a git repository merged with git merge -s ours. commit c1fbd66c031980f89e6b28862fe90813b1074c2e Merge: b5b8c5cec be3483fe9 Author: Joey Hess Date: 2014-02-23 14:19:39 -0400 Merge remote-tracking branch 'remotes/smcv/ready/git-push-origin-master' commit be3483fe9be559a62dd88577b3a374d55b7262f3 Author: Simon McVittie Date: 2014-02-21 11:23:17 +0000 git: explicitly specify the branch to push to origin git's behaviour when doing "git push origin" is configurable, and the default is going to change in 2.0. In particular, if you've set push.default to "nothing", the regression test will warn: fatal: You didn't specify any refspecs to push, and push.default is "nothing". 'git push origin' failed: at .../lib/IkiWiki/Plugin/git.pm line 220. commit d52774dd458059ba1442fdac1daf648dc4f228de Author: intrigeri Date: 2013-12-31 01:27:21 +0000 Do not UTF8-escape "/" in Git's diffurl: cgit does not support this. commit 441002e3e6b7f979eb4ef1d2525add2ea308ba6a Author: Joey Hess Date: 2013-11-16 20:48:23 -0400 deal with the case where oldrev is the same as newrev commit 727d39b92a90619027badbd4fd28d37a51c25d16 Author: Joey Hess Date: 2013-11-16 18:56:39 -0400 fix eq commit 654530fa8bb0937123ed526e3093170ef23f5295 Author: Joey Hess Date: 2013-11-16 17:26:20 -0400 Added only_committed_changes config setting, which speeds up wiki refresh by querying git to find the files that were changed, rather than looking at the work tree. Not enabled by default as it can break some setups where not all files get committed to git. commit 946af13ae60da6a8688e66bbe17dd1a012e5d747 Author: Joey Hess Date: 2013-07-10 21:52:43 -0400 Pass --no-edit when used with git 1.7.8 and newer. Not sure if this is needed to avoid it trying to run an editor. Probably there is never a controlling terminal and probably git notices and does nothing. But I'm just copying what I have in git-annex assistant here. (Although with a much worse git version comparion, that only really works due to luck.) commit b162563dc1c6126953e66cdcc508f389b9d39d8e Author: Joey Hess Date: 2013-07-10 21:48:16 -0400 Deal with git behavior change in 1.7.8 and newer that broke support for commits with an empty commit message. commit 12c9219d671c672fedcf9e9ab7f9187b23b8f7f4 Author: Shlomi Fish Date: 2012-12-17 22:44:54 +0200 Fix some warnigns in recent perls. All existing tests pass. --- diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 0c0e27521..75b89e476 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -29,6 +29,8 @@ sub import { hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert); hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); + hook(type => "rcs", id => "rcs_find_changes", call => \&rcs_find_changes); + hook(type => "rcs", id => "rcs_get_current_rev", call => \&rcs_get_current_rev); } sub checkconfig () { @@ -341,8 +343,8 @@ sub parse_diff_tree ($) { my $dt_ref = shift; # End of stream? - return if !defined @{ $dt_ref } || - !defined @{ $dt_ref }[0] || !length @{ $dt_ref }[0]; + return if ! @{ $dt_ref } || + !defined $dt_ref->[0] || !length $dt_ref->[0]; my %ci; # Header line. @@ -462,19 +464,65 @@ sub git_commit_info ($;$) { return wantarray ? @ci : $ci[0]; } -sub git_sha1 (;$) { - # Return head sha1sum (of given file). - my $file = shift || q{--}; +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', + '-r', "$oldrev..HEAD", '--', '.'); + + # Due to --reverse, we see changes in chronological order. + my %changed; + my %deleted; + my $nullsha = 0 x 40; + 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) { + if (! -e "$config{srcdir}/$file") { + delete $changed{$file}; + $deleted{$file}=1; + } + } + else { + if (-e "$config{srcdir}/$file") { + delete $deleted{$file}; + $changed{$file}=1; + } + } + } + } + + return (\%changed, \%deleted, $newrev); +} + +sub git_sha1_file ($) { + my $file=shift; + git_sha1("--", $file); +} + +sub git_sha1 (@) { # Ignore error since a non-existing file might be given. my ($sha1) = run_or_non('git', 'rev-list', '--max-count=1', 'HEAD', - '--', $file); + '--', @_); if (defined $sha1) { ($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now } return defined $sha1 ? $sha1 : ''; } +sub rcs_get_current_rev () { + git_sha1(); +} + sub rcs_update () { # Update working directory. @@ -488,7 +536,7 @@ sub rcs_prepedit ($) { # This will be later used in rcs_commit if a merge is required. my ($file) = @_; - return git_sha1($file); + return git_sha1_file($file); } sub rcs_commit (@) { @@ -499,7 +547,7 @@ sub rcs_commit (@) { # Check to see if the page has been changed by someone else since # rcs_prepedit was called. - my $cur = git_sha1($params{file}); + my $cur = git_sha1_file($params{file}); my ($prev) = $params{token} =~ /^($sha1_pattern)$/; # untaint if (defined $cur && defined $prev && $cur ne $prev) { @@ -550,7 +598,13 @@ sub rcs_commit_helper (@) { # Force git to allow empty commit messages. # (If this version of git supports it.) my ($version)=`git --version` =~ /git version (.*)/; - if ($version ge "1.5.4") { + if ($version ge "1.7.8") { + push @opts, "--allow-empty-message", "--no-edit"; + } + if ($version ge "1.7.2") { + push @opts, "--allow-empty-message"; + } + elsif ($version ge "1.5.4") { push @opts, '--cleanup=verbatim'; } else { @@ -564,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}); } } @@ -615,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;