summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdgit43
1 files changed, 25 insertions, 18 deletions
diff --git a/dgit b/dgit
index 54c38c2..54b0e6f 100755
--- a/dgit
+++ b/dgit
@@ -2700,6 +2700,18 @@ sub fetch_from_archive_record_2 ($) {
}
}
+sub parse_dsc_field ($$) {
+ my ($f, $what) = @_;
+ if (!defined $f) {
+ progress "$what: NO git hash";
+ } elsif ($f =~ m/^\w+/) {
+ $dsc_hash = $&;
+ progress "$what: specified git hash";
+ } else {
+ fail "$what: invalid Dgit info";
+ }
+}
+
sub fetch_from_archive () {
ensure_setup_existing_tree();
@@ -2711,17 +2723,12 @@ sub fetch_from_archive () {
get_archive_dsc();
if ($dsc) {
+ my $f;
foreach my $field (@ourdscfield) {
- $dsc_hash = $dsc->{$field};
- last if defined $dsc_hash;
- }
- if (defined $dsc_hash) {
- $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
- $dsc_hash = $&;
- progress "last upload to archive specified git hash";
- } else {
- progress "last upload to archive has NO git hash";
+ $f = $dsc->{$field};
+ last if defined $f;
}
+ parse_dsc_field($f, 'last upload to archive');
} else {
progress "no version available from the archive";
}
@@ -5891,31 +5898,31 @@ sub cmd_import_dsc {
parse_dscdata();
- my $dgit_commit = $dsc->{$ourdscfield[0]};
- if (defined $dgit_commit
+ my $dgit_field = $dsc->{$ourdscfield[0]};
+ parse_dsc_field($dgit_field, "$ourdscfield[0] field in .dsc");
+
+ if (defined $dsc_hash
&& !forceing [qw(import-dsc-with-dgit-field)]) {
- $dgit_commit =~ m/\w+/ or fail "invalid hash in .dsc";
- $dgit_commit = $&;
progress "dgit: import-dsc of .dsc with Dgit field, using git hash";
my @cmd = (qw(sh -ec),
- "echo $dgit_commit | git cat-file --batch-check");
+ "echo $dsc_hash | git cat-file --batch-check");
my $objgot = cmdoutput @cmd;
if ($objgot =~ m#^\w+ missing\b#) {
fail <<END
-.dsc contains Dgit field referring to object $dgit_commit
+.dsc contains Dgit field referring to object $dsc_hash
Your git tree does not have that object. Try `git fetch' from a
plausible server (browse.dgit.d.o? alioth?), and try the import-dsc again.
END
}
- if ($oldhash && !is_fast_fwd $oldhash, $dgit_commit) {
+ if ($oldhash && !is_fast_fwd $oldhash, $dsc_hash) {
if ($force > 0) {
progress "Not fast forward, forced update.";
} else {
- fail "Not fast forward to $dgit_commit";
+ fail "Not fast forward to $dsc_hash";
}
}
@cmd = (@git, qw(update-ref -m), "dgit import-dsc (Dgit): $info",
- $dstbranch, $dgit_commit);
+ $dstbranch, $dsc_hash);
runcmd @cmd;
progress "dgit: import-dsc updated git ref $dstbranch";
return 0;