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;
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");
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 ($$$) {
# 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';