X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-mv.perl;h=a21d87eea88d4b1e9a40e4e7f7b836374f566c70;hb=942c1f53aef03cb3d8b5c39b38997a379c3fad20;hp=28bced95954e40273fc783977d857e5c74d44b51;hpb=1114b26e8f2d06912d855c631e51a4ee8a06c4e2;p=git.git diff --git a/git-mv.perl b/git-mv.perl index 28bced95..a21d87ee 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -54,6 +54,8 @@ my ($src, $dst, $base, $dstDir); my $argCount = scalar @ARGV; if (-d $ARGV[$argCount-1]) { $dstDir = $ARGV[$argCount-1]; + # remove any trailing slash + $dstDir =~ s/\/$//; @srcArgs = @ARGV[0..$argCount-2]; foreach $src (@srcArgs) { @@ -77,7 +79,7 @@ else { my (@allfiles,@srcfiles,@dstfiles); my $safesrc; -my %overwritten; +my (%overwritten, %srcForDst); $/ = "\0"; open(F,"-|","git-ls-files","-z") @@ -123,6 +125,16 @@ while(scalar @srcArgs > 0) { } } + if ($bad eq "") { + if (defined $srcForDst{$dst}) { + $bad = "can not move '$src' to '$dst'; already target of "; + $bad .= "'".$srcForDst{$dst}."'"; + } + else { + $srcForDst{$dst} = $src; + } + } + if ($bad ne "") { if ($opt_k) { print "Warning: $bad; skipping\n";