mv: prevent mismatched data when ignoring errors.
We shrink the source and destination arrays, but not the modes or submodule_gitfile arrays, resulting in potentially mismatched data. Shrink all the arrays at the same time to prevent this. Add tests to ensure the problem does not recur. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
89ccc1b09c
commit
fb8a4e8079
@ -231,6 +231,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||
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
|
||||
|
Reference in New Issue
Block a user