From: Nguyễn Thái Ngọc Duy Date: Sun, 10 Aug 2014 02:29:30 +0000 (+0700) Subject: mv: flatten error handling code block X-Git-Tag: v2.2.0-rc0~140^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad1a19d0e7cdd69fd4902b80ab691d43b102e3e2;p=thirdparty%2Fgit.git mv: flatten error handling code block Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff --git a/builtin/mv.c b/builtin/mv.c index b892f63df9..c48129e301 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -225,24 +225,22 @@ int cmd_mv(int argc, const char **argv, const char *prefix) else string_list_insert(&src_for_dst, dst); - if (bad) { - if (ignore_errors) { - if (--argc > 0) { - memmove(source + i, source + i + 1, - (argc - i) * sizeof(char *)); - memmove(destination + i, - destination + i + 1, - (argc - i) * sizeof(char *)); - memmove(modes + i, modes + i + 1, - (argc - i) * sizeof(enum update_mode)); - memmove(submodule_gitfile + i, - submodule_gitfile + i + 1, - (argc - i) * sizeof(char *)); - i--; - } - } else - die (_("%s, source=%s, destination=%s"), - bad, src, dst); + if (!bad) + continue; + if (!ignore_errors) + die (_("%s, source=%s, destination=%s"), + bad, src, dst); + if (--argc > 0) { + int n = argc - i; + memmove(source + i, source + i + 1, + n * sizeof(char *)); + memmove(destination + i, destination + i + 1, + n * sizeof(char *)); + memmove(modes + i, modes + i + 1, + n * sizeof(enum update_mode)); + memmove(submodule_gitfile + i, submodule_gitfile + i + 1, + n * sizeof(char *)); + i--; } }