Skip to content

Commit

Permalink
Check another error condition in git-mv
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Weidendorfer authored and Junio C Hamano committed Oct 26, 2005
1 parent 979e32f commit 05ff564
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion git-mv.perl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ()

my (@allfiles,@srcfiles,@dstfiles);
my $safesrc;
my %overwritten;
my (%overwritten, %srcForDst);

$/ = "\0";
open(F,"-|","git-ls-files","-z")
Expand Down Expand Up @@ -123,6 +123,16 @@ ()
}
}

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";
Expand Down

0 comments on commit 05ff564

Please sign in to comment.