Re: [PATCH] optionally disable overwriting of ignored files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 20, 2010, 20:35 UTC
- Message-ID
- <7v4oepaup7.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20100818233900.GA27531@localhost>
If (and this may be a big IF) it is reasonable to add paths to .gitignore that you do not want to lose, then you would want to have three classes of untracked paths: "precious but ignored", "trashable" (and by definition ignored), and "unignored" (and by definition is not ignored and is precious).
As I already pointed out, we don't support the "precious but ignored" class. So an obvious alternate solution to your particular case is not to add such a path to the gitignore mechanism.
I have a suspicion that the approach this patch takes would not help very much in the real life. You just traded the lack of "precious but ignored" with "no file is trashable, even if it is listed in .gitignore".
Granted, as long as it is not default, it won't negatively affect people who do not enable it, other than that it may add maintenance burden on the resulting bloated code, but I find it hard to swallow new code that does not convincingly solve the real problem.
By the way, we seem to have a few longstanding bugs that trashes an unignored and untracked (hence by definition precious) path during branch switching, and does not give a correct escape hatch.
Doing this:
$ git checkout maint
$ echo foo >t/t2018-checkout-branch.sh
$ git checkout masterdoes correctly error out because the unignored file needs to be overwritten. But doing this after the above still errors out, which is probably wrong:
$ echo t/t2018-checkout-branch.sh >>.git/info/exclude
$ git checkout masterAfter doing the above:
$ ed .git/info/exclude ;# remove the extra entry in info/excludes
$d
w
q
$ rm t/t2018-checkout-branch.sh
$ echo foo >po
$ git checkout pushould error out, as "po" is a directory that has tracked contents, and we never said the untracked regular file "po" is trashable, but the above sequence happily checks the branch out.