mv: flatten error handling code block
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Aug 10, 2014 at 09:29 UTC
ad1a19d0e7cdd69fd4902b80ab691d43b102e3e2
1 file changed
+16
-18
builtin/mv.c
+16
-18
@@ -225,24 +225,22 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
225
else
226
string_list_insert(&src_for_dst, dst);
227
228
- if (bad) {
229
- if (ignore_errors) {
230
- if (--argc > 0) {
231
- memmove(source + i, source + i + 1,
232
- (argc - i) * sizeof(char *));
233
- memmove(destination + i,
234
- destination + i + 1,
235
- (argc - i) * sizeof(char *));
236
- memmove(modes + i, modes + i + 1,
237
- (argc - i) * sizeof(enum update_mode));
238
- memmove(submodule_gitfile + i,
239
- submodule_gitfile + i + 1,
240
- (argc - i) * sizeof(char *));
241
- i--;
242
- }
243
- } else
244
- die (_("%s, source=%s, destination=%s"),
245
- bad, src, dst);
228
+ if (!bad)
229
+ continue;
230
+ if (!ignore_errors)
231
+ die (_("%s, source=%s, destination=%s"),
232
+ bad, src, dst);
233
+ if (--argc > 0) {
234
+ int n = argc - i;
235
+ memmove(source + i, source + i + 1,
236
+ n * sizeof(char *));
237
+ memmove(destination + i, destination + i + 1,
238
+ n * sizeof(char *));
239
+ memmove(modes + i, modes + i + 1,
240
+ n * sizeof(enum update_mode));
241
+ memmove(submodule_gitfile + i, submodule_gitfile + i + 1,
242
+ n * sizeof(char *));
243
+ i--;
244
}
245
}
246