aboutsummaryrefslogtreecommitdiff
path: root/builtin-mv.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-08-16 02:20:32 +0200
committerJunio C Hamano <junkio@cox.net>2006-08-15 21:00:20 -0700
commit1d6249e609289940dca179b626fe4ae5433c90cc (patch)
tree030ff55edcc9723bac9c9b6f4e286f0d83bda377 /builtin-mv.c
parent66c4509b73eeb66de3196a43e3171b3764f74100 (diff)
downloadgit-1d6249e609289940dca179b626fe4ae5433c90cc.tar.gz
git-1d6249e609289940dca179b626fe4ae5433c90cc.tar.xz
git-mv: succeed even if source is a prefix of destination
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>
Diffstat (limited to 'builtin-mv.c')
-rw-r--r--builtin-mv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin-mv.c b/builtin-mv.c
index a731f8d9c..e7b5eb708 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -119,6 +119,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
/* Checking */
for (i = 0; i < count; i++) {
+ int length;
const char *bad = NULL;
if (show_only)
@@ -204,7 +205,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
}
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)