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

git apply fails silently when on the wrong directory

From
EAErnesto Alfonso <erjoalgo@gmail.com>
Date
Sep 27, 2017, 00:53 UTC
Message-ID
<87k20lt10c.fsf@gmail.com>
I recently ran into a similar issue as described here:
https://stackoverflow.com/questions/24821431/git-apply-patch-fails-silently-no-errors-but-nothing-happens
I was using the alias:
alias ganw='git diff -U0 -w --no-color "$@" | git apply --cached --ignore-whitespace --unidiff-zero -'

to stage non-whitespace changes, but I was not in the root directory and the changes were not being applied. I broke down the command to discover the 'git apply' part of the pipe was silently failing to apply anything, exiting 0 without even a warning.

The exit status and lack of warning is terribly misleading, I imagine this would be the cause of subtle bugs in automated scripts.

Is this expected behaviour?
Thanks,
Ernesto
Next: Ernesto Alfonso
Message 1 of 3 in “git apply fails silently when on the wrong directory”
  1. Ernesto AlfonsoSep 27, 2017
  2. Ernesto AlfonsoSep 27, 2017
  3. Jeff KingSep 27, 2017

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.