]> granicus.if.org Git - git/commitdiff
mv: flatten error handling code block
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 10 Aug 2014 02:29:30 +0000 (09:29 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Aug 2014 17:48:07 +0000 (10:48 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c

index b892f63df914015e97075ccfc0d7e7d3c854a5f6..c48129e301cdd4a8493089e423bce7cd56eaee8d 100644 (file)
@@ -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--;
                }
        }