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

Re: Gitignore matching "git add" wildcard prevents operation

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 15, 2010, 18:17 UTC
Message-ID
<7v7hrj1bd5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100115161107.GC12982@vidovic>
Nicolas Sebrecht <nicolas.s.dev@gmx.fr> writes:
>> My complaint was more that as a user, I am not likely to see this
>> problem and think "I'll bet git-specific globbing can solve it."
>
> Yes. My point is that we are not talking about a Git specific issue.

Actually it is. The thing is, git subcommands do *not* take individual filenames in general from their command line. They _always_ take pathspecs, find files in the work tree that match the pathspecs (but excludes ignored ones), and work on them [*1*].

Other commands usually don't do that.

So "git add ." and "git add 'a.*'" behave exactly the same way. Both find files that match their respective pathspecs. The former knows that "." matches "all files that exist in the cwd (excluding ignored ones)" and the latter knows that "a.*" matches "all files that fnmatch(3) 'a.*' glob (excluding ignored ones)". Hence you will not get "don't try to add a file that you said you want to ignore; use -f if you mean it".

[Footnote]

*1* There are exceptions, such as parameters to the "--file" option, and "git blame".

Previous: Nicolas SebrechtNext: Marko Poutiainen
Message 10 of 12 in “Gitignore matching "git add" wildcard prevents operation”
  1. Marko PoutiainenJan 14, 2010
  2. Jeff KingJan 14, 2010
  3. Junio C HamanoJan 14, 2010
  4. Jeff KingJan 14, 2010
  5. Nicolas SebrechtJan 15, 2010
  6. Jeff KingJan 15, 2010
  7. Nicolas SebrechtJan 15, 2010
  8. Jeff KingJan 15, 2010
  9. Nicolas SebrechtJan 15, 2010
  10. Junio C HamanoJan 15, 2010
  11. Marko PoutiainenJan 14, 2010
  12. Nicolas SebrechtJan 15, 2010

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.