Re: [PATCH v1 1/1] git stash needing mkdir deletes untracked file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 15, 2023, 18:03 UTC
- Message-ID
- <xmqqcyzoji7u.fsf@gitster.g>
- In-Reply-To
- <9f76de24-d337-ed41-fb81-888dba0b1656@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> I don't think we should be treating "git stash" as a special case here > - commands like "git checkout" should not be removing untracked files > unprompted either.
Yeah, I tend to agree. "git checkout branch path" should overwrite a leftover "path" in the working tree in response to such an explicit request, and that should equally apply for a request with pathspec e.g. "git checkout branch .", as the latter is also an explicit "please check out all paths out of the tree-ish of the branch".
But "git checkout branch" in a working tree with untracked "path" should not lose it if "branch" has it as a tracked file.
> I think stopping and telling the user that the file would be > overwritten as we do in other cases would be better.
Yup, that is what we have done and probably one of the design choices that made us successful.
Show 7 quoted lines
>> Reading the different reports and including own experience, >> I still think that a directory called ".deleted-by-user" >> or ".wastebin" or something in that style is a good idea. > > I can see an argument for being able to opt-in to that for "git > restore" and "git reset --hard" but that is a different problem to the > one here.
Yeah, I tend to agree. If anything, such a trash directory should be kept out-of-line, not inside the working tree. Perhaps in $HOME or somewhere, and not necessarily tied to the use of Git, as the way a file gets "deleted by user" is not necessarily limited to the use of Git.