summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 66c4509)
raw | patch | inline | side by side (parent: 66c4509)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Wed, 16 Aug 2006 00:20:32 +0000 (02:20 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 16 Aug 2006 04:00:20 +0000 (21:00 -0700) |
As noted by Fredrik Kuivinen, without this patch, git-mv fails on
git-mv README README-renamed
because "README" is a prefix of "README-renamed".
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-mv README README-renamed
because "README" is a prefix of "README-renamed".
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-mv.c | patch | blob | history | |
t/t7001-mv.sh | patch | blob | history |
diff --git a/builtin-mv.c b/builtin-mv.c
index a731f8d9cfed783fb59cb64db93f854ef0a4ebf9..e7b5eb7088dc3d45608a7d9b3ebaf1c66501596e 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
/* Checking */
for (i = 0; i < count; i++) {
+ int length;
const char *bad = NULL;
if (show_only)
}
if (!bad &&
- !strncmp(destination[i], source[i], strlen(source[i])))
+ (length = strlen(source[i])) >= 0 &&
+ !strncmp(destination[i], source[i], length) &&
+ (destination[i][length] == 0 || destination[i][length] == '/'))
bad = "can not move directory into itself";
if (!bad && cache_name_pos(source[i], strlen(source[i])) < 0)
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 900ca93cde02f82c35a59ee99349f9d0c4213867..e5e0bb9d513016c25956e18230dd4ba21fb2445b 100755 (executable)
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
git-diff-tree -r -M --name-status HEAD^ HEAD | \
grep -E "^R100.+path0/README.+path2/README"'
+test_expect_success \
+ 'succeed when source is a prefix of destination' \
+ 'git-mv path2/COPYING path2/COPYING-renamed'
+
test_expect_success \
'moving whole subdirectory into subdirectory' \
'git-mv path2 path1'