Re: [PATCHv3 4/4] rm: add absorb a submodules git dir before deletion
From: Junio C Hamano <hidden>
Date: 2016-12-15 00:03:10
Stefan Beller [off-list ref] writes:
if (list.entry[i].is_submodule) {
if (is_empty_dir(path)) {
+ if (rmdir(path))
+ die_errno("git rm: '%s'", path);
+ } else if (file_exists(path))
+ /* non empty directory: */Lose colon?
+ remove_directory_or_die(path);
... otherwise? I.e. else ??? If we are running "git rm -f <path>", then the path could be a submodule in the index and on the filesystem, it could be (1) already missing, as the user removed an empty submodule directory she is not interested in, (2) a non-directory, e.g. a file or a symbolic link, perhaps because she was trying to reorganize the superproject working tree but decided against it, or (3) something else? (1) is perfectly OK; we end up with a result without the path, which is what "git rm -f" wanted to do anyway. I am not sure what should happen in (2), and what other corner cases there are for (3), though. And use of file_exists(path) in the above patch may trigger a strange error message in case (2), as remove_directory_or_die() would say "path is not a directory", to which the user will say "Yes I know, I wanted you to remove it with 'git rm -f'".