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 <Josef.Weidendorfer@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Josef Weidendorfer committed
Oct 25, 2005 at 14:20 UTC
05ff5649a4fd90c3c80f507165bbaf07dc0dbe8e
1 file changed
+11
-1
git-mv.perl
+11
-1
@@ -77,7 +77,7 @@ else {
77
78
my (@allfiles,@srcfiles,@dstfiles);
79
my $safesrc;
80
-my %overwritten;
80
+my (%overwritten, %srcForDst);
81
82
$/ = "\0";
83
open(F,"-|","git-ls-files","-z")
@@ -123,6 +123,16 @@ while(scalar @srcArgs > 0) {
123
}
124
}
125
126
+ if ($bad eq "") {
127
+ if (defined $srcForDst{$dst}) {
128
+ $bad = "can not move '$src' to '$dst'; already target of ";
129
+ $bad .= "'".$srcForDst{$dst}."'";
130
+ }
131
+ else {
132
+ $srcForDst{$dst} = $src;
133
+ }
134
+ }
135
+
136
if ($bad ne "") {
137
if ($opt_k) {
138
print "Warning: $bad; skipping\n";