* git apply fails silently when on the wrong directory
@ 2017-09-27 0:53 Ernesto Alfonso
2017-09-27 0:55 ` Ernesto Alfonso
2017-09-27 1:25 ` Jeff King
0 siblings, 2 replies; 3+ messages in thread
From: Ernesto Alfonso @ 2017-09-27 0:53 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git apply fails silently when on the wrong directory
2017-09-27 0:53 git apply fails silently when on the wrong directory Ernesto Alfonso
@ 2017-09-27 0:55 ` Ernesto Alfonso
2017-09-27 1:25 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Ernesto Alfonso @ 2017-09-27 0:55 UTC (permalink / raw)
To: git
Also, has there been a feature request for a '-w' option to 'git add',
analogous to the same option in 'git diff'?
Ernesto Alfonso <erjoalgo@gmail.com> writes:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git apply fails silently when on the wrong directory
2017-09-27 0:53 git apply fails silently when on the wrong directory Ernesto Alfonso
2017-09-27 0:55 ` Ernesto Alfonso
@ 2017-09-27 1:25 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2017-09-27 1:25 UTC (permalink / raw)
To: Ernesto Alfonso; +Cc: git
On Tue, Sep 26, 2017 at 05:53:55PM -0700, Ernesto Alfonso wrote:
> 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?
Yes, this is as documented in git-apply(1):
Reads the supplied diff output (i.e. "a patch") and applies it to
files. When running from a subdirectory in a repository, patched
paths outside the directory are ignored.
I agree it's a potential source of confusion. There's some previous
discussion in this thread:
https://public-inbox.org/git/CA+DCAeQQQH59Lb43Y4Bi1xktPNoODV11KkUBbKNG1OZ7mDb-UQ@mail.gmail.com/
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-27 1:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27 0:53 git apply fails silently when on the wrong directory Ernesto Alfonso
2017-09-27 0:55 ` Ernesto Alfonso
2017-09-27 1:25 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).