1 Ikiwiki should really survive being asked to work with a git branch that has no existing commits.
5 GIT_DIR=barerepo.git git init
6 git clone barerepo.git srcdir
7 ikiwiki --rcs=git srcdir destdir
9 I've fixed this initial construction case, and, based on my testing, I've also fixed the post-update executing on a new master, and ikiwiki.cgi executing on a non-existent master cases.
11 Please commit so my users stop whining at me about having clean branches to push to, the big babies.
13 Summary: Change three scary loud failure cases related to empty branches into three mostly quiet success cases.
18 diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
19 index cf7fbe9..a1b5ed3 100644
20 --- a/IkiWiki/Plugin/git.pm
21 +++ b/IkiWiki/Plugin/git.pm
22 @@ -439,17 +439,20 @@ sub git_commit_info ($;$) {
25 push @opts, "--max-count=$num" if defined $num;
29 - my @raw_lines = run_or_die('git', 'log', @opts,
30 - '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
31 - '-r', $sha1, '--', '.');
32 + if (-e $config{srcdir} . '/.git/refs/heads/' . $config{gitmaster_branch}) {
33 + @raw_lines = run_or_die('git', 'log', @opts,
34 + '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
35 + '-r', $sha1, '--', '.');
38 - while (my $parsed = parse_diff_tree(\@raw_lines)) {
41 + while (my $parsed = parse_diff_tree(\@raw_lines)) {
45 - warn "Cannot parse commit info for '$sha1' commit" if !@ci;
46 + warn "Cannot parse commit info for '$sha1' commit" if !@ci;
49 return wantarray ? @ci : $ci[0];
51 @@ -474,7 +477,10 @@ sub rcs_update () {
52 # Update working directory.
54 if (length $config{gitorigin_branch}) {
55 - run_or_cry('git', 'pull', '--prune', $config{gitorigin_branch});
56 + run_or_cry('git', 'fetch', '--prune', $config{gitorigin_branch});
57 + if (-e $config{srcdir} . '/.git/refs/remotes/' . $config{gitorigin_branch} . '/' . $config{gitmaster_branch}) {
58 + run_or_cry('git', 'merge', $config{gitorigin_branch} . '/' . $config{gitmaster_branch});
63 @@ -559,7 +565,7 @@ sub rcs_commit_helper (@) {
64 # So we should ignore its exit status (hence run_or_non).
65 if (run_or_non('git', 'commit', '-m', $params{message}, '-q', @opts)) {
66 if (length $config{gitorigin_branch}) {
67 - run_or_cry('git', 'push', $config{gitorigin_branch});
68 + run_or_cry('git', 'push', $config{gitorigin_branch}, $config{gitmaster_branch});