1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-29 23:46:08 +02:00

Merge branch 'jc/builtin-mv-move-array'

Apply Coccinelle rule to turn raw memmove() into MOVE_ARRAY() cpp
macro, which would improve maintainability and readability.

* jc/builtin-mv-move-array:
  builtin/mv.c: use the MOVE_ARRAY() macro instead of memmove()
This commit is contained in:
Junio C Hamano 2022-07-18 13:31:53 -07:00
commit f01315ef7d

View File

@ -187,7 +187,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
die(_("index file corrupt"));
source = internal_prefix_pathspec(prefix, argv, argc, 0);
modes = xcalloc(argc, sizeof(enum update_mode));
CALLOC_ARRAY(modes, argc);
/*
* Keep trailing slash, needed to let
* "git mv file no-such-dir/" error out, except in the case
@ -376,14 +377,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
remove_entry:
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 *));
MOVE_ARRAY(source + i, source + i + 1, n);
MOVE_ARRAY(destination + i, destination + i + 1, n);
MOVE_ARRAY(modes + i, modes + i + 1, n);
MOVE_ARRAY(submodule_gitfile + i,
submodule_gitfile + i + 1, n);
i--;
}
}