We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 43134fc + 60a6bf5 commit e866ffdCopy full SHA for e866ffd
builtin-mv.c
@@ -26,7 +26,7 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
26
if (length > 0 && result[i][length - 1] == '/') {
27
char *without_slash = xmalloc(length);
28
memcpy(without_slash, result[i], length - 1);
29
- without_slash[length] = '\0';
+ without_slash[length - 1] = '\0';
30
result[i] = without_slash;
31
}
32
if (base_name) {
@@ -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) &&
+ 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
@@ -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
0 commit comments