Re: [RFC PATCH] Introduce "precious" file concept
- From
Matthieu Moy <git@matthieu-moy.fr>
- Date
- Nov 12, 2018, 09:08 UTC
- Message-ID
- <1205132135.1189562.1542013731020.JavaMail.zimbra@matthieu-moy.fr>
- In-Reply-To
- <591ab1f7-ef39-13e5-83b8-76fe372ecc2c@hibox.tv>
"Per Lundberg" <per.lundberg@hibox.tv> wrote:
Show 10 quoted lines
> On 11/11/18 5:41 PM, Duy Nguyen wrote: > > On Sun, Nov 11, 2018 at 1:33 PM Ævar Arnfjörð Bjarmason > > <avarab@gmail.com> wrote: > > >> That will lose no data, and in the very rare cases where a checkout of > >> tracked files would overwrite an ignored pattern, we can just error out > >> (as we do with the "Ok to overwrite" branch removed) and tell the user > >> to delete the files to proceed. > > There's also the other side of the coin. If this refuse to overwrite > > triggers too often, it can become an annoyance.
I may have missed some cases, but to me the cases when checkout may try to overwrite an ignored file are essentially:
* Someone "git add"ed a file meant to be ignored by mistake (e.g. "git add -f *.o").
* A file that was meant to be kept private (e.g. config.mak.dev) ends up being tracked. This may happen when we find a way to make per-developer settings the same for everyone.
I both cases I'd want at least to be notified that something is going on, and in the second I'd probably want to keep my local file around.
> If we feel thrashable is stretching it too far (which I don't think it > is), we could add a "core.ignore_files_are_trashable" setting that > brings back the old semantics, for those who have a strong feeling about it.
May I remind an idea I sugested in an old thread: add an intermediate level where ignored files to be overwritten are renamed (eg. foo -> foo~ like Emacs' backup files):
https://public-inbox.org/git/vpqd3t9656k.fsf@bauges.imag.fr/
One advantage of the "rename" behavior is that it's safer that the current, but still not very disturbing for people who like the current behavior. This makes it a good candidate for a default behavior.
This could come in complement with this thread's "precious" concept:
* If you know what you're doing and know that such or such file is precious, mark it as such and Git will never overwrite it.
* If you don't know about precious files, just keep the default setting and the worse that can happen is to get your file overwritten with a bakup of the old version kept around.
This would probably play better with a notion of "precious" files than with a notion of "trashable" files.
-- Matthieu Moy https://matthieu-moy.fr/