Merge branch 'maint'
* maint: builtin-mv: readability patch git-mv: fix off-by-one error git-mv: special case destination "."
This commit is contained in:
@ -26,7 +26,7 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
|
|||||||
if (length > 0 && result[i][length - 1] == '/') {
|
if (length > 0 && result[i][length - 1] == '/') {
|
||||||
char *without_slash = xmalloc(length);
|
char *without_slash = xmalloc(length);
|
||||||
memcpy(without_slash, result[i], length - 1);
|
memcpy(without_slash, result[i], length - 1);
|
||||||
without_slash[length] = '\0';
|
without_slash[length - 1] = '\0';
|
||||||
result[i] = without_slash;
|
result[i] = without_slash;
|
||||||
}
|
}
|
||||||
if (base_name) {
|
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));
|
modes = xcalloc(count, sizeof(enum update_mode));
|
||||||
dest_path = copy_pathspec(prefix, argv + argc - 1, 1, 0);
|
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)) {
|
S_ISDIR(st.st_mode)) {
|
||||||
dest_path[0] = add_slash(dest_path[0]);
|
dest_path[0] = add_slash(dest_path[0]);
|
||||||
destination = copy_pathspec(dest_path[0], argv + i, count, 1);
|
destination = copy_pathspec(dest_path[0], argv + i, count, 1);
|
||||||
|
@ -82,4 +82,8 @@ test_expect_failure \
|
|||||||
'do not move directory over existing directory' \
|
'do not move directory over existing directory' \
|
||||||
'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
|
'mkdir path0 && mkdir path0/path2 && git-mv path2 path0'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'move into "."' \
|
||||||
|
'git-mv path1/path2/ .'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user