chiark / gitweb /
Merge branch 'master' into wip.remote
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Nov 2013 00:14:53 +0000 (00:14 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 7 Nov 2013 00:14:53 +0000 (00:14 +0000)
Conflicts:
debian/changelog
dgit

debian/changelog
dgit

index a8f074d95c3474ab3042039e7f284ee5dbbc0cc8..f57b4acd78cd1028459476d2aa46c25517a9f8ff 100644 (file)
@@ -1,9 +1,18 @@
 dgit (0.18~experimental2) experimental; urgency=low
 
   * Merge in accidentally-dropped changes from 0.17~experimental7.
+  * Merge bugfix from master (unstable/testing) branch.
 
  --
 
+dgit (0.17) unstable; urgency=high
+
+  * Do not grobble around in .git/refs/; instead, use git-show-ref.
+    This avoids breaking when git makes packed refs.  Closes:728893.
+  * Clarify error message for missing refs/remotes/dgit/dgit/<suite>.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Thu, 07 Nov 2013 00:02:47 +0000
+
 dgit (0.18~experimental1) experimental; urgency=low
 
   * No update to code.
diff --git a/dgit b/dgit
index b8922dae0c76c9970446eb59fa4ea98deaf01420..2a5e26b0e0dcbca60b938a18e87c6fa09371316f 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -563,6 +563,23 @@ sub parsechangelog {
     return $c;
 }
 
+sub git_get_ref ($) {
+    my ($refname) = @_;
+    my $got = cmdoutput_errok @git, qw(show-ref --), $refname;
+    if (!defined $got) {
+       $?==256 or fail "git show-ref failed (status $?)";
+       printdebug "ref $refname= [show-ref exited 1]\n";
+       return '';
+    }
+    if ($got =~ m/^(\w+) \Q$refname\E$/m) {
+       printdebug "ref $refname=$1\n";
+       return $1;
+    } else {
+       printdebug "ref $refname= [no match]\n";
+       return '';
+    }
+}
+
 our %rmad;
 
 sub archive_query ($) {
@@ -983,22 +1000,13 @@ sub fetch_from_archive () {
        progress "no version available from the archive";
     }
 
-    my $lrref_fn = ".git/".lrref();
-    if (open H, $lrref_fn) {
-       $lastpush_hash = <H>;
-       chomp $lastpush_hash;
-       die "$lrref_fn $lastpush_hash ?" unless $lastpush_hash =~ m/^\w+$/;
-    } elsif ($! == &ENOENT) {
-       $lastpush_hash = '';
-    } else {
-       die "$lrref_fn $!";
-    }
+    $lastpush_hash = git_get_ref(lrref());
     printdebug "previous reference hash=$lastpush_hash\n";
     my $hash;
     if (defined $dsc_hash) {
-       fail "missing git history even though dsc has hash -".
-           " could not find commit $dsc_hash".
-           " (should be in ".access_giturl()."#".rrref().")"
+       fail "missing remote git history even though dsc has hash -".
+           " could not find ref ".lrref().
+           " (should have been fetched from ".access_giturl()."#".rrref().")"
            unless $lastpush_hash;
        $hash = $dsc_hash;
        ensure_we_have_orig();