threads / bug / 61873

Possible bug or error in document?

Subject: Possible bug or error in document?

## tl;dr

2 messages between Jul 31, 2024 and Jul 31, 2024.

replies: 1people: 2as markdown or json

KwonHyun Kim· Jul 31, 2024, 06:08 UTC · lore
Hello there, I have a possible bug or possible error in document.
  When I do `git add --pathspec-from=.gitadd --ignore-errors` I can
the following error

``` $ git add --pathspec-from=.gitadd --ignore-errors fatal: pathspec 'chapter???.R' did not match any files ```

  I figured from what I read from the help, --ignore-errors means add
whatever possible(help included in the following)
--ignore-errors
           If some files could not be added because of errors indexing
them, do not abort the operation, but continue adding the others. The
command shall still exit with non-zero
           status. The configuration variable add.ignoreErrors can be
set to true to make this the default behaviour.
  So is it me possibly misunderstanding English, or it might be git
doing something wrong or document directing someone in the wrong
direction...
  I thought I might use this option(--pathsepc-from=) like using
.gitignore in the opposite way but it seems that I need to make my own
script to read line by line and do `git add`
  Thank you for reading.
KwH Kim
Junio C Hamano· Jul 31, 2024, 15:44 UTC · re: KwonHyun Kim · lore

Re: Possible bug or error in document?

KwonHyun Kim <kwonhyun.kim@gmail.com> writes:
Show 6 quoted lines
> --ignore-errors
>            If some files could not be added because of errors indexing
> them, do not abort the operation, but continue adding the others. The
> command shall still exit with non-zero
>            status. The configuration variable add.ignoreErrors can be
> set to true to make this the default behaviour.

I think "--ignore-errors" is meant to ignore errors only about "adding" a discovered path (i.e. the exact path that user wants to add) to the index. Perhaps the file exists, but an I/O error prevents Git from reading it fully, causing it to fail computing the blob object name. Such an error is ignored and other paths that got successfully computed their hashes are added to the index.

On the other hand, errors while discovering what exact paths the user wants to add are not ignored. So "git add --ignore-errors -- no-such-file" would still error out in order to notify you that you asked for no-such-file that does not exist, and "--pathspec-from" does not change the story.

What is missing from "git add" might be the "--ignore-unmatch" option that "git rm" has. There are other commands that supports a similarly named "--ignore-missing" option, and we may #leftoverbits want to unify them over time (i.e. decide which one to use in the longer term, say "--ignore-missing", teach "git rm" that "--ignore-missing" is a new synonym for "--ignore-unmatch", add "--ignore-missing" to "git add" and probably other commands that would benefit from having it, and then in a far enough future, retire "--ignore-unmatch" from "git rm").

← back to recent threads