Skip to content

Commit c5203bd

Browse files
dschoJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d78b0f3 commit c5203bd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

builtin-mv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
114114
modes = xcalloc(count, sizeof(enum update_mode));
115115
dest_path = copy_pathspec(prefix, argv + argc - 1, 1, 0);
116116

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) &&
118121
S_ISDIR(st.st_mode)) {
119122
dest_path[0] = add_slash(dest_path[0]);
120123
destination = copy_pathspec(dest_path[0], argv + i, count, 1);

t/t7001-mv.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ test_expect_failure \
8282
'do not move directory over existing directory' \
8383
'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
8484

85+
test_expect_success \
86+
'move into "."' \
87+
'git-mv path1/path2/ .'
88+
8589
test_done

0 commit comments

Comments
 (0)