X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=ef815997de84c0e581f3f4d7bf3347ebcb64dd08;hb=612c3e10d7d797a48798fa82578760eea2231103;hp=809d0b9d06fc713de3d6eb70ea689007576a0aed;hpb=5c9ed5c0a77935dca8bb6f0c1cf6181d2ee54e48;p=dgit.git diff --git a/dgit b/dgit index 809d0b9d..ef815997 100755 --- a/dgit +++ b/dgit @@ -5281,6 +5281,13 @@ sub cmd_import_dsc { badusage "dry run makes no sense with import-dsc" unless act_local(); + my $force = $dstbranch =~ s/^\+// ? +1 : + $dstbranch =~ s/^\.\.// ? -1 : + 0; + my $info = $force ? " $&" : ''; + $info = "$dscfn$info"; + + my $specbranch = $dstbranch; $dstbranch = "refs/heads/$dstbranch" unless $dstbranch =~ m#^refs/#; $dstbranch = cmdoutput @git, qw(check-ref-format --normalize), $dstbranch; @@ -5291,6 +5298,8 @@ sub cmd_import_dsc { fail "$dstbranch is checked out - will not update it" if defined $chead and $chead eq $dstbranch; + my $oldhash = git_get_ref $dstbranch; + open D, "<", $dscfn or fail "open import .dsc ($dscfn): $!"; $dscdata = do { local $/ = undef; ; }; D->error and fail "read $dscfn: $!"; @@ -5312,13 +5321,27 @@ 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 } - @cmd = (@git, qw(update-ref -m), "dgit import-dsc (Dgit): $dscfn", + if ($oldhash && !is_fast_fwd $oldhash, $dgit_commit) { + if ($force > 0) { + progress "Not fast forward, forced update."; + } else { + fail "Not fast forward to $dgit_commit"; + } + } + @cmd = (@git, qw(update-ref -m), "dgit import-dsc (Dgit): $info", $dstbranch, $dgit_commit); runcmd @cmd; progress "dgit: import-dsc updated git ref $dstbranch"; return 0; } + fail < 0) { + progress "Import, forced update - synthetic orphan git history."; + } elsif ($force < 0) { + progress "Import, merging."; + my $tree = cmdoutput @git, qw(rev-parse), "$newhash:"; + my $version = getfield $dsc, 'Version'; + $newhash = make_commit_text <