]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/headless_git_branches.mdwn
Danish translation update. Closes: #625721
[ikiwiki.git] / doc / todo / headless_git_branches.mdwn
1 Ikiwiki should really survive being asked to work with a git branch that has no existing commits.
2
3     mkdir iki-gittest
4     cd iki-gittest
5     GIT_DIR=barerepo.git git init
6     git clone barerepo.git srcdir
7     ikiwiki --rcs=git srcdir destdir
8
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. Unfortunately these cases still generate a lot of warnings from recentchanges; I suspect a much more invasive patch would be needed to shut those up.
10
11 Please commit so my users stop whining at me about having clean branches to push to, the big babies.
12
13 Summary: Change three scary loud failure cases related to empty branches into three scary loud success cases.
14
15 [[!tag patch]]
16
17 <pre>
18 diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
19 index cf7fbe9..5b1e334 100644
20 --- a/IkiWiki/Plugin/git.pm
21 +++ b/IkiWiki/Plugin/git.pm
22 @@ -439,10 +439,13 @@ sub git_commit_info ($;$) {
23  
24         my @opts;
25         push @opts, "--max-count=$num" if defined $num;
26 +        my @raw_lines;
27  
28 -       my @raw_lines = run_or_die('git', 'log', @opts,
29 -               '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
30 -               '-r', $sha1, '--', '.');
31 +        if (-e $config{srcdir} . "/.git/refs/heads/" . $config{gitmaster_branch}) {
32 +                @raw_lines = run_or_die('git', 'log', @opts,
33 +                        '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
34 +                        '-r', $sha1, '--', '.');
35 +        };
36  
37         my @ci;
38         while (my $parsed = parse_diff_tree(\@raw_lines)) {
39 @@ -474,7 +477,10 @@ sub rcs_update () {
40         # Update working directory.
41  
42         if (length $config{gitorigin_branch}) {
43 -               run_or_cry('git', 'pull', '--prune', $config{gitorigin_branch});
44 +                run_or_cry('git', 'fetch', '--prune', $config{gitorigin_branch});
45 +                if (-e $config{srcdir} . '/.git/refs/remotes/' . $config{gitorigin_branch} . '/' . $config{gitmaster_branch}) {
46 +                        run_or_cry('git', 'merge', $config{gitorigin_branch} . '/' . $config{gitmaster_branch});
47 +                }
48         }
49  }
50  
51 @@ -559,7 +565,7 @@ sub rcs_commit_helper (@) {
52         # So we should ignore its exit status (hence run_or_non).
53         if (run_or_non('git', 'commit', '-m', $params{message}, '-q', @opts)) {
54                 if (length $config{gitorigin_branch}) {
55 -                       run_or_cry('git', 'push', $config{gitorigin_branch});
56 +                       run_or_cry('git', 'push', $config{gitorigin_branch}, $config{gitmaster_branch});
57                 }
58         }
59 </pre>