git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git add $ignored_file" fail

From
Linus Torvalds <torvalds@osdl.org>
Date
May 17, 2006, 23:20 UTC
Message-ID
<Pine.LNX.4.64.0605171614250.10823@g5.osdl.org>
In-Reply-To
<7vd5ecb688.fsf@assigned-by-dhcp.cox.net>
On Wed, 17 May 2006, Junio C Hamano wrote:
> 
> If you give a pattern that would match two files but one of them
> were hidden by .gitignore, this approach would not help you
> much.
Correct. On the other hand, what could you do?
I think that the common case for that is literally something like
	git add dirname/
or
	git add file*

and it turns out that there are object files under the directory, or that there's a file.c, file.h _and_ a already-compiled file.o file.

Under both of those circumstances (one pattern that matches multiple files but ignores others - or several different patterns where _some_ of the patterns are ignored), we actually do what I think is the only sane thing.

Namely to just silently add everything that makes sense to add.
Show 5 quoted lines
> Even if we wanted to say something like "if the user explicitly
> tells us to add etc/mtab~ by spelling it out, we should ignore
> *~ entry in .gitignore", the shell expansion bites us because it
> is done before we get to what the user give us.  We cannot
> distinguish that with the user typing etc/?tab* for example.
Right.

The only case that we cando anything at all about is really the case where we didn't add anything at all, and then we might reasonably ask "do you know what the heck you're doing".

That's kind of what my last patch did. It's a total special case, but it's the _only_ special case that I can see that is at all relevant (ie in all other cases it would just be annoying as _hell_ if we started talking about how we're ignoring object files. Of _course_ we're ignoring them, and that's why they are listed in .gitignore).

So I'd love to have the built-in "git add", but quite frankly, if you drop that last patch as "too ugly to live", I certainly won't complain. I sent it out more as a "we -could- do this" thing rather than anything more serious.

			Linus
Previous: Junio C Hamano
Message 18 of 18 in “"git add $ignored_file" fail”
  1. SantiMay 16, 2006
  2. Linus TorvaldsMay 16, 2006
  3. Jakub NarebskiMay 16, 2006
  4. SantiMay 16, 2006
  5. Johannes SchindelinMay 17, 2006
  6. SantiMay 17, 2006
  7. Jakub NarebskiMay 17, 2006
  8. Pavel RoskinMay 17, 2006
  9. SeanMay 17, 2006
  10. Jakub NarebskiMay 17, 2006
  11. Johannes SchindelinMay 17, 2006
  12. Linus TorvaldsMay 17, 2006
  13. Pavel RoskinMay 17, 2006
  14. Linus TorvaldsMay 17, 2006
  15. Jakub NarebskiMay 17, 2006
  16. Linus TorvaldsMay 17, 2006
  17. Junio C HamanoMay 17, 2006
  18. Linus TorvaldsMay 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.