@matheusbsbs / matheus-bagliano / commits / c5203bdf66
Fork 0

git-mv: special case destination "."

Since the normalized basename of "." is "", the check for directory failed erroneously. Noticed by Fredrik Kuivinen. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Aug 18, 2006 at 12:42 UTC c5203bdf66531c848a2b6cd74f3c02cb18286c55
2 files changed +8 -1
builtin-mv.c
+4 -1
@@ -114,7 +114,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
114 modes = xcalloc(count, sizeof(enum update_mode));
115 dest_path = copy_pathspec(prefix, argv + argc - 1, 1, 0);
116
117 - if (!lstat(dest_path[0], &st) &&
117 + if (dest_path[0][0] == '\0')
118 + /* special case: "." was normalized to "" */
119 + destination = copy_pathspec(dest_path[0], argv + i, count, 1);
120 + else if (!lstat(dest_path[0], &st) &&
121 S_ISDIR(st.st_mode)) {
122 dest_path[0] = add_slash(dest_path[0]);
123 destination = copy_pathspec(dest_path[0], argv + i, count, 1);
t/t7001-mv.sh
+4
@@ -82,4 +82,8 @@ test_expect_failure \
82 'do not move directory over existing directory' \
83 'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
84
85 +test_expect_success \
86 + 'move into "."' \
87 + 'git-mv path1/path2/ .'
88 +
89 test_done