diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2014-08-10 09:29:34 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-03 15:06:52 -0700 |
commit | b46b15dea01a898888fac977aeed6055a761c3ca (patch) | |
tree | ab449024455dc4cc8b847decc1b30f156be26f22 /builtin/mv.c | |
parent | e2b6cfa02e29c4a8f91ede15026b5eaa790de329 (diff) | |
download | git-b46b15dea01a898888fac977aeed6055a761c3ca.tar.gz git-b46b15dea01a898888fac977aeed6055a761c3ca.tar.xz |
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>
Diffstat (limited to 'builtin/mv.c')
-rw-r--r-- | builtin/mv.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/builtin/mv.c b/builtin/mv.c index 42a04d2b8..4f324aea1 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -171,43 +171,36 @@ int cmd_mv(int argc, const char **argv, const char *prefix) && lstat(dst, &st) == 0) bad = _("cannot move directory over file"); else if (src_is_dir) { - int first = cache_name_pos(src, length); + int first = cache_name_pos(src, length), last; if (first >= 0) prepare_move_submodule(src, first, submodule_gitfile + i); - else { - int last; + else if (index_range_of_same_dir(src, length, + &first, &last) < 1) + bad = _("source directory is empty"); + else { /* last - first >= 1 */ + int j, dst_len, n; modes[i] = WORKING_DIRECTORY; - index_range_of_same_dir(src, length, &first, &last); - if (last - first < 1) - bad = _("source directory is empty"); - else { - int j, dst_len, n; + n = argc + last - first; + source = xrealloc(source, n * sizeof(char *)); + destination = xrealloc(destination, n * sizeof(char *)); + modes = xrealloc(modes, n * sizeof(enum update_mode)); + submodule_gitfile = xrealloc(submodule_gitfile, n * sizeof(char *)); - n = argc + last - first; - source = xrealloc(source, n * sizeof(char *)); - 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); + dst_len = strlen(dst); - dst = add_slash(dst); - dst_len = strlen(dst); - - for (j = 0; j < last - first; j++) { - const char *path = - active_cache[first + j]->name; - source[argc + j] = path; - destination[argc + j] = - prefix_path(dst, dst_len, - path + length + 1); - modes[argc + j] = INDEX; - submodule_gitfile[argc + j] = NULL; - } - argc += last - first; + for (j = 0; j < last - first; j++) { + const char *path = active_cache[first + j]->name; + source[argc + j] = path; + destination[argc + j] = + prefix_path(dst, dst_len, path + length + 1); + modes[argc + j] = INDEX; + submodule_gitfile[argc + j] = NULL; } + argc += last - first; } } else if (cache_name_pos(src, length) < 0) bad = _("not under version control"); |