Skip to content

Commit ad1a19d

Browse files
pcloudsgitster
authored andcommitted
mv: flatten error handling code block
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eac0ccc commit ad1a19d

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

builtin/mv.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,24 +225,22 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
225225
else
226226
string_list_insert(&src_for_dst, dst);
227227

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--;
246244
}
247245
}
248246

0 commit comments

Comments
 (0)