]> git.ipfire.org Git - thirdparty/git.git/commit - dir.c
dir: new flag to remove_dir_recurse() to spare the original_cwd
authorElijah Newren <newren@gmail.com>
Thu, 9 Dec 2021 05:08:34 +0000 (05:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Dec 2021 21:33:13 +0000 (13:33 -0800)
commit580a5d7f75fc7b6c4c369ef429742d9d417acddd
treedb3789482029387549d85a8976ebb612e181e81d
parent63bbe8beb78ee8af5a7faeee4be747a82d8e2dc7
dir: new flag to remove_dir_recurse() to spare the original_cwd

remove_dir_recurse(), and its non-static wrapper called
remove_dir_recursively(), both take flags for modifying its behavior.
As with the previous commits, we would generally like to protect
the original_cwd, but we want to forced user commands (e.g. 'git rm -rf
...') or other special cases to remove it.  Add a flag for this purpose.
After reading through every caller of remove_dir_recursively() in the
current codebase, there was only one that should be adjusted and that
one only in a very unusual circumstance.  Add a pair of new testcases to
highlight that very specific case involving submodules && --git-dir &&
--work-tree.

Acked-by: Derrick Stolee <stolee@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rm.c
dir.c
dir.h
t/t2501-cwd-empty.sh