From: Josef Weidendorfer Date: Tue, 25 Oct 2005 12:20:45 +0000 (+0200) Subject: Check another error condition in git-mv X-Git-Tag: v0.99.9~46 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05ff5649a4fd90c3c80f507165bbaf07dc0dbe8e;p=git.git Check another error condition in git-mv When moving multiple files at once, it can happen that files get the same target name, like in git-mv a/foo b/foo destdir Both a/foo and b/foo target destdir/foo. Signed-off-by: Josef Weidendorfer Signed-off-by: Junio C Hamano --- diff --git a/git-mv.perl b/git-mv.perl index 28bced959..17e35b0ac 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -77,7 +77,7 @@ else { my (@allfiles,@srcfiles,@dstfiles); my $safesrc; -my %overwritten; +my (%overwritten, %srcForDst); $/ = "\0"; open(F,"-|","git-ls-files","-z") @@ -123,6 +123,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";