From 86ad8bd4c1026392b4b758e8c0cfd6b39c3cfc03 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 6 Nov 2013 23:52:20 +0000 Subject: Do not grobble around in .git/refs/; instead, use git-show-ref. This avoids breaking when git makes packed refs. Closes:728893. --- debian/changelog | 7 +++++++ dgit | 28 ++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index c1f58d3..9f31f38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 ba5f1ba..16bf56d 100755 --- 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 = ; - 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) { -- cgit v1.2.3 From 631c9e09a7fd22a5847173978c3d1357c1db74ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 7 Nov 2013 00:02:52 +0000 Subject: Clarify error message for missing refs/remotes/dgit/dgit/. --- debian/changelog | 3 ++- dgit | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9f31f38..eab01a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ 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/. - -- + -- Ian Jackson Thu, 07 Nov 2013 00:02:47 +0000 dgit (0.16) unstable; urgency=high diff --git a/dgit b/dgit index 16bf56d..207b5d0 100755 --- a/dgit +++ b/dgit @@ -745,9 +745,9 @@ sub fetch_from_archive () { print DEBUG "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(); -- cgit v1.2.3