summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fbf8ac2)
raw | patch | inline | side by side (parent: fbf8ac2)
author | Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | |
Wed, 23 Nov 2005 11:04:23 +0000 (12:04 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 24 Nov 2005 00:51:26 +0000 (16:51 -0800) |
This is fixed by putting the file into @changedfiles/@addedfiles,
and not the directory this file is in.
Additionally, this fixes the behavior for attempting to overwrite
a file with a directory, and gives a message for all cases where
overwriting is not possible (file->dir,dir->file,dir->dir).
Thanks for Alexander Litvinov for noting this problem.
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
and not the directory this file is in.
Additionally, this fixes the behavior for attempting to overwrite
a file with a directory, and gives a message for all cases where
overwriting is not possible (file->dir,dir->file,dir->dir).
Thanks for Alexander Litvinov for noting this problem.
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-mv.perl | patch | blob | history |
diff --git a/git-mv.perl b/git-mv.perl
index a21d87eea88d4b1e9a40e4e7f7b836374f566c70..bf54c38413c02553bd314d24bfdadc4cdb23ccce 100755 (executable)
--- a/git-mv.perl
+++ b/git-mv.perl
$bad = "bad source '$src'";
}
+ $safesrc = quotemeta($src);
+ @srcfiles = grep /^$safesrc(\/|$)/, @allfiles;
+
$overwritten{$dst} = 0;
if (($bad eq "") && -e $dst) {
$bad = "destination '$dst' already exists";
- if (-f $dst && $opt_f) {
- print "Warning: $bad; will overwrite!\n";
- $bad = "";
- $overwritten{$dst} = 1;
+ if ($opt_f) {
+ # only files can overwrite each other: check both source and destination
+ if (-f $dst && (scalar @srcfiles == 1)) {
+ print "Warning: $bad; will overwrite!\n";
+ $bad = "";
+ $overwritten{$dst} = 1;
+ }
+ else {
+ $bad = "Can not overwrite '$src' with '$dst'";
+ }
}
}
}
if ($bad eq "") {
- $safesrc = quotemeta($src);
- @srcfiles = grep /^$safesrc(\/|$)/, @allfiles;
if (scalar @srcfiles == 0) {
$bad = "'$src' not under version control";
}
push @deletedfiles, @srcfiles;
if (scalar @srcfiles == 1) {
+ # $dst can be a directory with 1 file inside
if ($overwritten{$dst} ==1) {
- push @changedfiles, $dst;
+ push @changedfiles, $dstfiles[0];
+
} else {
- push @addedfiles, $dst;
+ push @addedfiles, $dstfiles[0];
}
}
else {