chiark / gitweb /
Split brain: Do not look at all of %INC for cache key
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 835366eaed8a5efd42878ce52c261f73e56397b9..a5685375caf02def49d22c0e93033ffec0568a11 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2994,15 +2994,10 @@ END
 
 sub quilt_check_splitbrain_cache ($$) {
     my ($headref, $upstreamversion) = @_;
-    # Checks to see if we are in (potentially) split brain mode.
-    # If so, computes the cache key and looks in the cache.
-    # If split brain is not applicable, returns (undef,0).
-    # Otherwise returns ($cachekey,HIT) where
-    # HIT=0: miss; HIT=1: hit, needs different commit; HIT=2: same commit OK
-
-    quilt_make_fake_dsc($upstreamversion);
-
-    return (undef,0) unless quiltmode_splitbrain();
+    # Called only if we are in (potentially) split brain mode.
+    # Called in $ud.
+    # Computes the cache key and looks in the cache.
+    # Returns ($dgit_view_commitid, $cachekey) or (undef, $cachekey)
 
     my $splitbrain_cachekey;
     
@@ -3020,6 +3015,7 @@ sub quilt_check_splitbrain_cache ($$) {
     my $srcshash = Digest::SHA->new(256);
     my %sfs = ( %INC, '$0(dgit)' => $0 );
     foreach my $sfk (sort keys %sfs) {
+       next unless m/^\$0\b/ || m{^Debian/Dgit\b};
        $srcshash->add($sfk,"  ");
        $srcshash->add(hashfile($sfs{$sfk}));
        $srcshash->add("\n");
@@ -3052,16 +3048,16 @@ sub quilt_check_splitbrain_cache ($$) {
            progress "dgit view: found cached (commit id $cachehit)";
            runcmd @git, qw(checkout -q -b dgit-view), $cachehit;
            $split_brain = 1;
-           return ($splitbrain_cachekey, 1);
+           return ($cachehit, $splitbrain_cachekey);
        }
        progress "dgit view: found cached, no changes required";
-       return ($splitbrain_cachekey, 2);
+       return ($headref, $splitbrain_cachekey);
     }
     die $! if GC->error;
     failedcmd unless close GC;
 
     printdebug "splitbrain cache miss\n";
-    return ($splitbrain_cachekey, 0);
+    return (undef, $splitbrain_cachekey);
 }
 
 sub quilt_fixup_multipatch ($$$) {
@@ -3138,10 +3134,16 @@ sub quilt_fixup_multipatch ($$$) {
     # afterwards with dpkg-source --before-build.  That lets us save a
     # tree object corresponding to .origs.
 
-    my ($splitbrain_cachekey,$cachehit) =
-       quilt_check_splitbrain_cache($headref, $upstreamversion);
+    my $splitbrain_cachekey;
+
+    quilt_make_fake_dsc($upstreamversion);
 
-    return if $splitbrain_cachekey && $cachehit;
+    if (quiltmode_splitbrain()) {
+       my $cachehit;
+       ($cachehit, $splitbrain_cachekey) =
+           quilt_check_splitbrain_cache($headref, $upstreamversion);
+       return if $cachehit;
+    }
 
     runcmd qw(sh -ec),
         'exec dpkg-source --no-check --skip-patches -x fake.dsc >/dev/null';