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

Re: suppress fatal pathspec errors from "git add"?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 3, 2010, 08:12 UTC
Message-ID
<7vk4vz38v0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100103074058.GB23031@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> ... I could see it
> if your workflow were something like "in a script, add these N files if
> they exist, but it is not an error if they don't". But I still don't
> think you would want to ignore all errors; you would want to do
> something like:
>
>   $ git add $(for i in foo bar baz; do test -e $i && echo $i; done)
>
> instead. Am I missing something?
If your primary activity that happens in the work tree were:
	while :
        do
        	file=$(date +"random-%H%M%S")
                >"$file"
                rm -f "$file"
	done
and your add were done in
	while sleep 3600
        do
		git add $(for i in *; do test -e $i && echo $i; done)
                git commit -m "hourly snapshot"
	done

totally asynchronously without coordinating with what the primary activity is doing, your "test -e && echo" can race with a concurrent "rm".

Even though I think it is an insane use pattern that we shouldn't bother to bend too much backwards to support it, --ignore-errors were added primarily for a similar use case (i.e. by the time we try to read it, it is either gone or it cannot be read by the user who runs "git add"), so in that sense it _might_ make sense to ignore all errors with the option. If we choose to go in that direction, it would also make tons of sense to update the documentation of the option to caution more strongly that its use is a sign of insanity and is discouraged at the same time.

Previous: aaron smithNext: Jeff King
Message 4 of 6 in “suppress fatal pathspec errors from "git add"?”
  1. aaron smithDec 31, 2009
  2. Jeff KingJan 3, 2010
  3. aaron smithJan 3, 2010
  4. Junio C HamanoJan 3, 2010
  5. Jeff KingJan 3, 2010
  6. Jakub NarebskiJan 3, 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.