Hi Phillip, On Tue, Nov 30, 2021 at 3:04 AM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote: > > Hi Elijah > > On 26/11/2021 22:40, Elijah Newren via GitGitGadget wrote: > > 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"). Many commands either > > silently avoid removing directories that are not empty (i.e. those that have > > untracked or modified files in them)[1], or show an error and abort, > > depending on which is more appropriate for the command in question. With > > this series, we augment the reasons to avoid removing directories to include > > not just has-untracked-or-modified-files, but also to avoid removing the > > original_cwd as well. > > > > Peff and Junio provided some good pros/cons, if it helps: > > > > * Pros: Peff (original suggester of the idea)[2], and Junio[3] > > * Cons: Peff [2, again -- see the "P.S."], and Junio[4] > > > > [1] well, with a few exceptions; see > > https://lore.kernel.org/git/pull.1036.v3.git.1632760428.gitgitgadget@xxxxxxxxx/ > > [2] https://lore.kernel.org/git/YS8eEtwQvF7TaLCb@xxxxxxxxxxxxxxxxxxxxxxx/ > > [3] https://lore.kernel.org/git/xmqqo86elyht.fsf@gitster.g/ [4] > > https://lore.kernel.org/git/xmqqo8691gr8.fsf@gitster.g/ > > > Thanks for working on this, I'm sorry I haven't had time to take a > proper look at it but I think it is a good idea. I did notice that > you're using ":/" in patch 8 and wondered what happens if some runs 'git > --literal-pathspecs stash' but I haven't looked properly. Interesting point. The --literal-pathspecs passed to stash is not passed along to the git clean subprocess, and we only use the ":/" pathspec with this subprocess. This means whereas before we'd always run git clean --force --quiet -d [-x] from the toplevel, now we run git clean --force --quiet -d :/ [-x] from the relevant subdirectory. So, I don't think I've introduced any bug here. (Now, the fact that we use a git clean subprocess instead of just calling the appropriate library functions is IMO a design/implementation bug, but a longstanding one.)