From 05ff5649a4fd90c3c80f507165bbaf07dc0dbe8e Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Tue, 25 Oct 2005 14:20:45 +0200 Subject: [PATCH] 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 --- git-mv.perl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/git-mv.perl b/git-mv.perl index 28bced95..17e35b0a 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"; -- 2.11.0