summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-10-20 15:55:57 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-10-20 16:10:49 +0100
commit50048b4c1c41e1471cdc7054bed02ff30418ea44 (patch)
tree0639404945229682c8152720a478c9be61469987 /dgit
parenta17cad7ce9f5d5a89c77cd9179d4fb33076e493f (diff)
split brain cache: Add a dummy ref update when necessary
git-update-ref does not make a new reflog entry if the ref is not actually being changed. This can mean that `dgit build' might fail to find a good cache entry, but also fail to generate one that push will accept. In this case, generate a dummy reflog update. We make a spurious child of the $dgitview, as that's straightforward. Giving it the same tree and a parent means that human use of reflog commands will produce empty results rather than lots of confusing output. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit16
1 files changed, 16 insertions, 0 deletions
diff --git a/dgit b/dgit
index 9fcd1fc..7ca97c5 100755
--- a/dgit
+++ b/dgit
@@ -3917,6 +3917,22 @@ END
ensuredir ".git/logs/refs/dgit-intern";
my $makelogfh = new IO::File ".git/logs/refs/$splitbraincache", '>>'
or die $!;
+
+ my $oldcache = git_get_ref "refs/$splitbraincache";
+ if ($oldcache eq $dgitview) {
+ my $tree = cmdoutput qw(git rev-parse), "$dgitview:";
+ # git update-ref doesn't always update, in this case. *sigh*
+ my $dummy = make_commit_text <<END;
+tree $tree
+parent $dgitview
+author Dgit <dgit\@example.com> 1000000000 +0000
+committer Dgit <dgit\@example.com> 1000000000 +0000
+
+Dummy commit - do not use
+END
+ runcmd @git, qw(update-ref -m), "dgit $our_version - dummy",
+ "refs/$splitbraincache", $dummy;
+ }
runcmd @git, qw(update-ref -m), $cachekey, "refs/$splitbraincache",
$dgitview;