From 05ff5649a4fd90c3c80f507165bbaf07dc0dbe8e Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Tue, 25 Oct 2005 14:20:45 +0200 Subject: 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 28bced9..17e35b0 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"; -- cgit v0.10.2-6-g49f6