summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2013-11-07 00:14:53 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2013-11-07 00:14:53 +0000
commit641eeadd77583420e7ad32d6a0414a24f4fc83bb (patch)
treece8800f1d680c667e398265865de79e3922a49d4 /dgit
parente7bf758b02322662a888d347d13243501d109b74 (diff)
parent631c9e09a7fd22a5847173978c3d1357c1db74ea (diff)
Merge branch 'master' into wip.remote
Conflicts: debian/changelog dgit
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit34
1 files changed, 21 insertions, 13 deletions
diff --git a/dgit b/dgit
index b8922da..2a5e26b 100755
--- 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();