"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > Traditionally, if folks run git commands such as checkout or rebase from a > subdirectory, that git command could remove their current working directory > and result in subsequent git and non-git commands either getting confused or > printing messages that confuse the user (e.g. "fatal: Unable to read current > working directory: No such file or directory"). We already refuse to remove > directories that have untracked files within them[1], preferring to show an > error; with this series, we tweak that rule a bit to also refuse to remove > the current working directory even if it has no untracked files within it. The goal is roughly that we do not allow rmdir() of a directory at "prefix" in the working tree, or any parent directory of it, for functions that uses RUN_SETUP? By the time we attempt to rmdir(), most likely we'd chdir()'ed up to the top of the working tree ourselves, so we need to remember where the original cwd was when we started, and protecting the original cwd would mean that we protect the directory in which the process that spawned us, like the user's interactive shell, is still sitting, which makes sense.