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

[PATCH v2 0/1] add: respect --ignore-errors when lstat() reports errors

From
QGQusielle via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 3, 2019, 20:26 UTC
Message-ID
<pull.432.v2.git.1572812819.gitgitgadget@gmail.com>
In-Reply-To
<pull.432.git.1572127149.gitgitgadget@gmail.com>

"git add --ignore-errors" command fails immediately when lstat returns an error, despite the ignore errors' flag is enabled.

There could be files that triggers an error on stat(), when other files proceed correctly. Issue can be reproduced when running git under Cygwin and some target files have utf-8 long names (200+ utf chars). Windows can handle them, but all operations on them failed under Cygwin. Issue can not be reproduced with usual latin/numeric only names. For example, create a file with 220 'й' letters by Windows Explorer, then in Cygwin:

Here and below "ййй..." means the line of й copied 220 times. =============================================================

$ echo -n 'ййй...' | wc -c # check the real size 440

$ ls -la ls: cannot access 'ййй...'$'\320': No such file or directory -????????? ? ? ? ? ? 'ййй...'$'\320'

$ ls й* ls: cannot access 'ййй...'$'\320': No such file or directory
$ stat й* stat: cannot stat 'ййй...'$'\320': No such file or directory

In my perspective, it's okay to skip these problematic files when ignore error flag is specified, but official Git terminates entire git add command when such files come up. But with proposed patch it is the desired behavior:

$ git add --ignore-errors . error: ййй... can only add regular files, symbolic links or git-directories

All other files have been added correctly. ==========================================

Signed-off-by: Qusielle <qusielle@gmail.com>
qusielle (1):
  add: respect `--ignore-errors` when `lstat()` reports errors
 read-cache.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
base-commit: 566a1439f6f56c2171b8853ddbca0ad3f5098770
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-432%2Fqusielle%2Fmaster-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-432/qusielle/master-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/432
Range-diff vs v1:
 1:  fd022f88f5 ! 1:  d88ea544d9 add: respect `--ignore-errors` when `lstat()` reports errors
     @@ -46,7 +46,13 @@
       {
       	struct stat st;
      -	if (lstat(path, &st))
     -+	if (lstat(path, &st) && !(flags & ADD_CACHE_IGNORE_ERRORS))
     - 		die_errno(_("unable to stat '%s'"), path);
     +-		die_errno(_("unable to stat '%s'"), path);
     ++	if (lstat(path, &st)) {
     ++		if (flags & ADD_CACHE_IGNORE_ERRORS)
     ++			return -1;
     ++		else
     ++			die_errno(_("unable to stat '%s'"), path);
     ++	}
       	return add_to_index(istate, path, &st, flags);
       }
     + 
-- 
gitgitgadget
Previous: qusielle@gmail.comNext: qusielle via GitGitGadget
Message 5 of 6 in “add: respect --ignore-errors when lstat() reports errors”
  1. 0/1 add: respect --ignore-errors when lstat() reports errorsQusielle via GitGitGadget, Oct 26, 2019
  2. 1/1 add: respect `--ignore-errors` when `lstat()` reports errorsqusielle via GitGitGadget, Oct 26, 2019
  3. Junio C HamanoOct 28, 2019
  4. qusielle@gmail.comNov 3, 2019
  5. 0/1 add: respect --ignore-errors when lstat() reports errorsQusielle via GitGitGadget, Nov 3, 2019
  6. 1/1 add: respect `--ignore-errors` when `lstat()` reports errorsqusielle via GitGitGadget, Nov 3, 2019

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.