mv: unindent one level for directory move code

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2014-08-10 09:29:34 +07:00 committed by Junio C Hamano
parent e2b6cfa02e
commit b46b15dea0

View File

@ -171,43 +171,36 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
&& lstat(dst, &st) == 0) && lstat(dst, &st) == 0)
bad = _("cannot move directory over file"); bad = _("cannot move directory over file");
else if (src_is_dir) { else if (src_is_dir) {
int first = cache_name_pos(src, length); int first = cache_name_pos(src, length), last;
if (first >= 0) if (first >= 0)
prepare_move_submodule(src, first, prepare_move_submodule(src, first,
submodule_gitfile + i); submodule_gitfile + i);
else { else if (index_range_of_same_dir(src, length,
int last; &first, &last) < 1)
bad = _("source directory is empty");
else { /* last - first >= 1 */
int j, dst_len, n;
modes[i] = WORKING_DIRECTORY; modes[i] = WORKING_DIRECTORY;
index_range_of_same_dir(src, length, &first, &last); n = argc + last - first;
if (last - first < 1) source = xrealloc(source, n * sizeof(char *));
bad = _("source directory is empty"); destination = xrealloc(destination, n * sizeof(char *));
else { modes = xrealloc(modes, n * sizeof(enum update_mode));
int j, dst_len, n; submodule_gitfile = xrealloc(submodule_gitfile, n * sizeof(char *));
n = argc + last - first; dst = add_slash(dst);
source = xrealloc(source, n * sizeof(char *)); dst_len = strlen(dst);
destination = xrealloc(destination, n * sizeof(char *));
modes = xrealloc(modes, n * sizeof(enum update_mode));
submodule_gitfile =
xrealloc(submodule_gitfile, n * sizeof(char *));
dst = add_slash(dst); for (j = 0; j < last - first; j++) {
dst_len = strlen(dst); const char *path = active_cache[first + j]->name;
source[argc + j] = path;
for (j = 0; j < last - first; j++) { destination[argc + j] =
const char *path = prefix_path(dst, dst_len, path + length + 1);
active_cache[first + j]->name; modes[argc + j] = INDEX;
source[argc + j] = path; submodule_gitfile[argc + j] = NULL;
destination[argc + j] =
prefix_path(dst, dst_len,
path + length + 1);
modes[argc + j] = INDEX;
submodule_gitfile[argc + j] = NULL;
}
argc += last - first;
} }
argc += last - first;
} }
} else if (cache_name_pos(src, length) < 0) } else if (cache_name_pos(src, length) < 0)
bad = _("not under version control"); bad = _("not under version control");