Skip to content

Commit

Permalink
mv: flatten error handling code block
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 11, 2014
1 parent eac0ccc commit ad1a19d
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}
}

Expand Down

0 comments on commit ad1a19d

Please sign in to comment.