Re: [PATCH 5/5] git-add: add ignored files when asked explicitly.
- From
Junio C Hamano <junkio@cox.net>
- Date
- Dec 25, 2006, 17:27 UTC
- Message-ID
- <7vslf3khsc.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.63.0612251443230.19693@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 11 quoted lines
> On Mon, 25 Dec 2006, Junio C Hamano wrote: > >> $ git add foo.o >> $ git add '*.o' > > Most people do > > $ git add *.o > > instead, where bash expands the expression. Maybe this new behaviour > should be hidden between a "-f" option?
When would anybody do "git add *.o"?
A more plausible situation is that you have '*.o' in .gitignore because you do not want to keep track of object files generated from your source, but your project needs to keep track of one third-party object file that you do not have the source to, and helping that situation is what this patch is about.
An alternative is to use the mechanism I added here to _detect_ the attempt to add an ignored file with explicitly spelled out pathspec, and issue an info message that says something like:
Path 'xyzzy/filfre.o' is not being ignored by one of your .gitignore files. If you really want to add it, please add this entry to .gitignore file:
!/xyzzy/filfre.o
One advantage of this is that it would help guiding the user in the right direction, giving a reusable piece of knowledge, without changing the behaviour of the command (what is refused is refused). But I can already see people's complaints: if the tool knows how to fix that situation why forces the user to do so?
Although the reason why the alternative does not do so is "The user earlier said *.o files are uninteresting but came back with a conflicting request to add xyzzy/filfre.o, which could be a mistake. We ask for a confirmation", which is very sensible, another alternative would be to add the path anyway and issue an warning, like this:
$ ls xyzzy
filfre.c filfre.o
$ git add xyzzy/filfre.?
added ignored path xyzzy/filfre.o