summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-08 03:01:39 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-08 22:14:48 +0000
commit71437159c44af0328fc4bbc1826be18e4f057444 (patch)
treeb3b3540648c77483db3ab53d30646b3cbfdab506
parentc4ff745bf2423178860cb7ab6905f0cd6565c37b (diff)
git fetching: git_lrfetch_sane: Support multiple calls
We want to be able to fetch from some other distro, or a bit more from the same one. No functional change since no callers pass trueish $supplementary. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-xdgit26
1 files changed, 20 insertions, 6 deletions
diff --git a/dgit b/dgit
index 4f6d111..c66c7a6 100755
--- a/dgit
+++ b/dgit
@@ -2515,7 +2515,14 @@ sub lrfetchref_used ($) {
}
sub git_lrfetch_sane {
- my (@specs) = @_;
+ my ($supplementary, @specs) = @_;
+ # Make a 'refs/'.lrfetchrefs.'/*' be just like on server,
+ # at least as regards @specs. Also leave the results in
+ # %lrfetchrefs_f, and arrange for lrfetchref_used to be
+ # able to clean these up.
+ #
+ # With $supplementary==1, @specs must not contain wildcards
+ # and we add to our previous fetches (non-atomically).
# This is rather miserable:
# When git fetch --prune is passed a fetchspec ending with a *,
@@ -2541,18 +2548,19 @@ sub git_lrfetch_sane {
my $url = access_giturl();
- printdebug "git_lrfetch_sane specs @specs\n";
+ printdebug "git_lrfetch_sane suppl=$supplementary specs @specs\n";
my $specre = join '|', map {
my $x = $_;
$x =~ s/\W/\\$&/g;
- $x =~ s/\\\*$/.*/;
+ my $wildcard = $x =~ s/\\\*$/.*/;
+ die if $wildcard && $supplementary;
"(?:refs/$x)";
} @specs;
printdebug "git_lrfetch_sane specre=$specre\n";
my $wanted_rref = sub {
local ($_) = @_;
- return m/^(?:$specre)$/o;
+ return m/^(?:$specre)$/;
};
my $fetch_iteration = 0;
@@ -2595,7 +2603,9 @@ END
my @fcmd = (@git, qw(fetch -p -n -q), $url, @fspecs);
runcmd_ordryrun_local @fcmd if @fspecs;
- %lrfetchrefs_f = ();
+ if (!$supplementary) {
+ %lrfetchrefs_f = ();
+ }
my %objgot;
git_for_each_ref(lrfetchrefs, sub {
@@ -2604,6 +2614,10 @@ END
$objgot{$objid} = 1;
});
+ if ($supplementary) {
+ last;
+ }
+
foreach my $lrefname (sort keys %lrfetchrefs_f) {
my $rrefname = 'refs'.substr($lrefname, length lrfetchrefs);
if (!exists $wantr{$rrefname}) {
@@ -2663,7 +2677,7 @@ sub git_fetch_us () {
push @specs, $rewritemap;
push @specs, qw(heads/*) if deliberately_not_fast_forward;
- git_lrfetch_sane @specs;
+ git_lrfetch_sane 0, @specs;
my %here;
my @tagpats = debiantags('*',access_nomdistro);