chiark / gitweb /
dgit: Be more careful about tag updates during fetch: only update tags referring...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2015 18:19:40 +0000 (19:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2015 20:38:47 +0000 (21:38 +0100)
debian/changelog
dgit

index ef2c8423d152c079c4a1867711399004de31a815..b798cbd64be6852c86965833dd18f8ce9c914ec8 100644 (file)
@@ -91,6 +91,8 @@ dgit (0.23~) unstable; urgency=low
   * Change realpath dependency to `coreutils (>= 8.23-1~) | realpath'
     (Closes:#786955.)
   * For non-Debian distros, debiantag() uses distro name a la DEP-14.
   * Change realpath dependency to `coreutils (>= 8.23-1~) | realpath'
     (Closes:#786955.)
   * For non-Debian distros, debiantag() uses distro name a la DEP-14.
+  * dgit: Be more careful about tag updates during fetch: only update
+    tags referring to uploads to distro we are trying to fetch from.
 
  --
 
 
  --
 
diff --git a/dgit b/dgit
index 47e05f79727dda47e76dc230851300c97d26b0fc..ea9652438ff5b4935609d29d21824845519e8c75 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1343,12 +1343,33 @@ sub ensure_we_have_orig () {
 }
 
 sub git_fetch_us () {
 }
 
 sub git_fetch_us () {
-    runcmd_ordryrun_local @git, qw(fetch),access_giturl(),fetchspec();
-    if (deliberately_not_fast_forward) {
-       runcmd_ordryrun_local @git, qw(fetch -p), access_giturl(),
-           map { "+refs/$_/*:".lrfetchrefs."/$_/*" }
-           qw(tags heads);
-    }
+    my @specs = (fetchspec());
+    push @specs,
+        map { "+refs/$_/*:".lrfetchrefs."/$_/*" }
+        qw(tags heads);
+    runcmd_ordryrun_local @git, qw(fetch -p -n), access_giturl(), @specs;
+
+    my %here;
+    my $tagpat = debiantag('*',access_basedistro);
+
+    git_for_each_ref("refs/tags/".$tagpat, sub {
+       my ($objid,$objtype,$fullrefname,$reftail) = @_;
+       printdebug "currently $fullrefname=$objid\n";
+       $here{$fullrefname} = $objid;
+    });
+    git_for_each_ref(lrfetchrefs."/tags/".$tagpat, sub {
+       my ($objid,$objtype,$fullrefname,$reftail) = @_;
+       my $lref = "refs".substr($fullrefname, length lrfetchrefs);
+       printdebug "offered $lref=$objid\n";
+       if (!defined $here{$lref}) {
+           my @upd = (@git, qw(update-ref), $lref, $objid, '');
+           runcmd_ordryrun_local @upd;
+       } elsif ($here{$lref} eq $objid) {
+       } else {
+           print STDERR \
+               "Not updateting $lref from $here{$lref} to $objid.\n";
+       }
+    });
 }
 
 sub fetch_from_archive () {
 }
 
 sub fetch_from_archive () {