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

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

From
ASaaron smith <beingthexemplarylists@gmail.com>
Date
Jan 3, 2010, 08:00 UTC
Message-ID
<d7ac1a681001030000n431d420ajb9b4733ad83ddecd@mail.gmail.com>
In-Reply-To
<20100103074058.GB23031@sigill.intra.peff.net>
Hey Jeff, thanks for the reply.

Yeah you hit it right on the head, it would be useful to suppress the errors if you're running a script to add the files. I can certainly use that snippet u provided - thanks. It would even be useful in git if you could suppress the errors, or maybe have a switch to list out the files that failed, but add the ones that pass.. like "git add --ignore-errors --list-failures" something like that. Anyway, thanks for the input.

On Sat, Jan 2, 2010 at 11:40 PM, Jeff King <peff@peff.net> wrote:
Show 42 quoted lines
> On Thu, Dec 31, 2009 at 01:24:59PM -0800, aaron smith wrote:
>
>> I'm looking through the add documentation, I don't see a way to
>> suppress fatal pathspec errors? For example, if I'm adding 5 files,
>> but one of them is mis-spelled, can I have git just supress the errors
>> and add the other four?
>
> Hmm. I would have thought "git add --ignore-errors" would do what you
> want, but it only ignores errors in reading the file. If we can't stat
> it, we will always die. IMHO that is an oversight in how
> "--ignore-errors" works (why should this one particular error be treated
> as fatal, when others are not?).
>
> However, I have to wonder what your workflow is to really want this. If
> you do:
>
>  $ ls
>  foo bar baz
>  $ git add foo bar bz
>  fatal: pathspec 'bz' did not match any files
>
> Then presumably your next command would be:
>
>  $ git add foo bar baz
>
> Using ignore-errors (if it worked), you would probably do:
>
>  $ git add baz
>
> Less typing, I suppose, but presumably you are using a shell that
> lets you just go back and edit the previous command line. 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?
>
> -Peff
>
Previous: Jeff KingNext: Junio C Hamano
Message 3 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.