chiark / gitweb /
split brain cache: Add a dummy ref update when necessary
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 20 Oct 2016 14:55:57 +0000 (15:55 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 20 Oct 2016 15:10:49 +0000 (16:10 +0100)
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>
debian/changelog
dgit

index 99e724d00609a33b5d6e2839c6b55e0537b1603f..08b3e32364e685173de9f63acb7699bc52021ee7 100644 (file)
@@ -6,6 +6,10 @@ dgit (2.4~) unstable; urgency=low
     Closes:#841100.
   * split brain cache: Fix a wrong implicit reference to $_.
     Closes:#841383.
+  * split brain cache: Make sure to write reflog entries for cache updates
+    even if the eventual tree (and therefore commit) is the same.
+    Otherwise, after updating dgit, the cache might have the right answer
+    but not be refreshed even by a build.
 
  --
 
diff --git a/dgit b/dgit
index 9fcd1fcc40508cc34a5c51956e69ec5b44312cdb..7ca97c57f018f5b59df7ca92aa6868f8fa8ee503 100755 (executable)
--- 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;