chiark / gitweb /
Do not grobble around in .git/refs/; instead, use git-show-ref. This avoids breaking...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 6 Nov 2013 23:52:20 +0000 (23:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 6 Nov 2013 23:52:20 +0000 (23:52 +0000)
debian/changelog
dgit

index c1f58d3b89097d0fbe50638d0b7b105c3e85bf06..9f31f38c6a6d73f9e53c5395428e04cd11c06302 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
+ --
+
 dgit (0.16) unstable; urgency=high
 
   * Format `(3.0) quilt' fixup does not mind extraneous other files
diff --git a/dgit b/dgit
index ba5f1ba8295c6b8d176411eddf3599d3786ea73b..16bf56d9a8dbc445ecef087eb3422e77e6389c32 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -358,6 +358,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 $?)";
+       print DEBUG "ref $refname= [show-ref exited 1]\n";
+       return '';
+    }
+    if ($got =~ m/^(\w+) \Q$refname\E$/m) {
+       print DEBUG "ref $refname=$1\n";
+       return $1;
+    } else {
+       print DEBUG "ref $refname= [no match]\n";
+       return '';
+    }
+}
+
 our %rmad;
 
 sub archive_query ($) {
@@ -724,16 +741,7 @@ sub fetch_from_archive () {
        print "no version available from the archive\n";
     }
 
-    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());
     print DEBUG "previous reference hash=$lastpush_hash\n";
     my $hash;
     if (defined $dsc_hash) {