aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-21 14:16:38 -0700
committerJunio C Hamano <junkio@cox.net>2006-08-21 14:16:38 -0700
commite866ffdf9b2add0e0981d19b3c212c4621fd8a57 (patch)
tree48e095a799e70f3a4245bc02be2acdbb4fff1cf2
parent43134fcb350fb70d26634be163db1f71c14db19f (diff)
parent60a6bf5f53635005f4f68d8b8a33172309193623 (diff)
downloadgit-e866ffdf9b2add0e0981d19b3c212c4621fd8a57.tar.gz
git-e866ffdf9b2add0e0981d19b3c212c4621fd8a57.tar.xz
Merge branch 'maint'
* maint: builtin-mv: readability patch git-mv: fix off-by-one error git-mv: special case destination "."
-rw-r--r--builtin-mv.c7
-rwxr-xr-xt/t7001-mv.sh4
2 files changed, 9 insertions, 2 deletions
diff --git a/builtin-mv.c b/builtin-mv.c
index 1fdb0c77f..ff882bec4 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -26,7 +26,7 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
if (length > 0 && result[i][length - 1] == '/') {
char *without_slash = xmalloc(length);
memcpy(without_slash, result[i], length - 1);
- without_slash[length] = '\0';
+ without_slash[length - 1] = '\0';
result[i] = without_slash;
}
if (base_name) {
@@ -114,7 +114,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
modes = xcalloc(count, sizeof(enum update_mode));
dest_path = copy_pathspec(prefix, argv + argc - 1, 1, 0);
- if (!lstat(dest_path[0], &st) &&
+ if (dest_path[0][0] == '\0')
+ /* special case: "." was normalized to "" */
+ destination = copy_pathspec(dest_path[0], argv + i, count, 1);
+ else if (!lstat(dest_path[0], &st) &&
S_ISDIR(st.st_mode)) {
dest_path[0] = add_slash(dest_path[0]);
destination = copy_pathspec(dest_path[0], argv + i, count, 1);
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index e5e0bb9d5..b7fcdb390 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -82,4 +82,8 @@ test_expect_failure \
'do not move directory over existing directory' \
'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
+test_expect_success \
+ 'move into "."' \
+ 'git-mv path1/path2/ .'
+
test_done