X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=ef815997de84c0e581f3f4d7bf3347ebcb64dd08;hb=4fcc733b6194bdee895424cab72874e98ea42816;hp=88df4ef5eedeaf0bca604e477067dc2b53d18b49;hpb=893e94307ff001da9fc13b28c94ed27d17f48b60;p=dgit.git diff --git a/dgit b/dgit index 88df4ef5..ef815997 100755 --- a/dgit +++ b/dgit @@ -5281,9 +5281,25 @@ 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; + my @symcmd = (@git, qw(symbolic-ref -q HEAD)); + my $chead = cmdoutput_errok @symcmd; + defined $chead or $?==256 or failedcmd @symcmd; + + 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: $!"; @@ -5305,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 <