Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
OPT_END(),
Comment thread
ffyuanda marked this conversation as resolved.
};
const char **source, **destination, **dest_path, **submodule_gitfile;
enum update_mode *modes;
enum update_mode *modes, dst_mode = 0;
struct stat st;
struct string_list src_for_dst = STRING_LIST_INIT_NODUP;
struct lock_file lock_file = LOCK_INIT;
Expand Down Expand Up @@ -207,9 +207,15 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
dest_path[0] = add_slash(dest_path[0]);
destination = internal_prefix_pathspec(dest_path[0], argv, argc, DUP_BASENAME);
} else {
if (argc != 1)
if (!check_dir_in_index(dest_path[0])) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message mentions that this should only be done if '--sparse' is provided ("Change the logic so that when supplied with --sparse...", but I don't see any validation of that flag here. Is that done implicitly as part of 'check_dir_in_index()'? If so, it would help to have a comment in this if/else block clarifying that.

dest_path[0] = add_slash(dest_path[0]);
destination = internal_prefix_pathspec(dest_path[0], argv, argc, DUP_BASENAME);
dst_mode |= SKIP_WORKTREE_DIR;
} else if (argc != 1) {
die(_("destination '%s' is not a directory"), dest_path[0]);
destination = dest_path;
} else {
destination = dest_path;
}
}

/* Checking */
Expand Down