2011-04-23 23:54:06 +02:00
Ikiwiki should really survive being asked to work with a git branch that has no existing commits.
mkdir iki-gittest
cd iki-gittest
GIT_DIR=barerepo.git git init
git clone barerepo.git srcdir
ikiwiki --rcs=git srcdir destdir
2011-05-02 08:09:45 +02:00
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.
2011-04-23 23:54:06 +02:00
Please commit so my users stop whining at me about having clean branches to push to, the big babies.
2011-05-02 08:09:45 +02:00
Summary: Change three scary loud failure cases related to empty branches into three mostly quiet success cases.
2011-04-30 21:55:14 +02:00
[[!tag patch]]
2011-04-23 23:54:06 +02:00
<pre>
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
2011-05-03 09:43:55 +02:00
index cf7fbe9..e5bafcf 100644
2011-04-23 23:54:06 +02:00
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
2011-05-03 09:43:55 +02:00
@@ -439,17 +439,21 @@ sub git_commit_info ($;$) {
2011-04-23 23:54:06 +02:00
my @opts;
push @opts, "--max-count=$num" if defined $num;
2011-05-03 09:43:55 +02:00
-
2011-04-23 23:54:06 +02:00
- my @raw_lines = run_or_die('git', 'log', @opts,
- '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
- '-r', $sha1, '--', '.');
2011-05-03 09:43:55 +02:00
-
+ my @raw_lines;
my @ci;
2011-05-02 08:09:45 +02:00
- while (my $parsed = parse_diff_tree(\@raw_lines)) {
- push @ci, $parsed;
- }
2011-05-03 09:43:55 +02:00
+
+ # Test to see if branch actually exists yet.
+ if (run_or_non('git', 'show-ref', '--quiet', '--verify', '--', 'refs/heads/' . $config{gitmaster_branch}) ) {
+ @raw_lines = run_or_die('git', 'log', @opts,
+ '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
+ '-r', $sha1, '--', '.');
+
2011-05-02 08:09:45 +02:00
+ while (my $parsed = parse_diff_tree(\@raw_lines)) {
+ push @ci, $parsed;
+ }
- warn "Cannot parse commit info for '$sha1' commit" if !@ci;
+ warn "Cannot parse commit info for '$sha1' commit" if !@ci;
+ };
return wantarray ? @ci : $ci[0];
}
2011-05-03 09:43:55 +02:00
@@ -474,7 +478,10 @@ sub rcs_update () {
2011-04-23 23:54:06 +02:00
# Update working directory.
if (length $config{gitorigin_branch}) {
- run_or_cry('git', 'pull', '--prune', $config{gitorigin_branch});
2011-05-02 08:09:45 +02:00
+ run_or_cry('git', 'fetch', '--prune', $config{gitorigin_branch});
2011-05-03 09:43:55 +02:00
+ if (run_or_non('git', 'show-ref', '--quiet', '--verify', '--', 'refs/remotes/' . $config{gitorigin_branch} . '/' . $config{gitmaster_branch}) ) {
2011-05-02 08:09:45 +02:00
+ run_or_cry('git', 'merge', $config{gitorigin_branch} . '/' . $config{gitmaster_branch});
+ }
2011-04-23 23:54:06 +02:00
}
}
2011-05-03 09:43:55 +02:00
@@ -559,7 +566,7 @@ sub rcs_commit_helper (@) {
2011-04-23 23:54:06 +02:00
# 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});
}
}
2011-05-02 08:09:45 +02:00
2011-04-23 23:54:06 +02:00
</pre>