git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Steffen Nurpmeso <sdaoden@yandex.com>, git@vger.kernel.org
Subject: Re: `ab | (cd cd && git apply -)' fails with v2.0.0
Date: Fri, 25 Jul 2014 08:49:06 +0200	[thread overview]
Message-ID: <53D1FDE2.8030309@drmicha.warpmail.net> (raw)
In-Reply-To: <xmqqegxaad3r.fsf@gitster.dls.corp.google.com>

Junio C Hamano venit, vidit, dixit 24.07.2014 19:19:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> Steffen Nurpmeso venit, vidit, dixit 24.07.2014 15:29:
>>> Hello (again, psssssst, after a long time),
>>>
>>> it happened yesterday that i needed to do
>>>
>>>   $ git diff HEAD:FILE COMMIT:SAME-FILE |
>>>   > (cd src && git apply -) 
>>> ...
>>
>> Ah little more context would help. Are you diffing files in the subdir
>> src, or a file at the root which happens to be present in the subdir src
>> as well?
> 
> As the <treeish>:<path> form is not meant to produce "git apply"
> applicable patch in the first place, I am not sure what the OP is
> trying to achieve in the first place.  Not just "how many leading
> levels to strip?" but "which file is being modified?" does not
> appear in a usable form.  For example, here is what you would see:
> 
>     $ git diff HEAD:GIT-VERSION-GEN maint:GIT-VERSION-GEN
>     diff --git a/HEAD:GIT-VERSION-GEN b/maint:GIT-VERSION-GEN
>     index 40adbf7..0d1a86c 100755
>     --- a/HEAD:GIT-VERSION-GEN
>     +++ b/maint:GIT-VERSION-GEN
>     @@ -1,7 +1,7 @@
>     ...
> 
> and neither "HEAD:GIT-VERSION-GEN" nor "maint:GIT-VERSION-GEN" is
> the file being modified ("GIT-VERSION-GEN" is).

I thought "git apply" knows how to strip the rev part.

> I would understand if the upstream of the pipe were
> 
>     $ git diff HEAD maint -- GIT-VERSION-GEN | ...
> 
> though.
> 
> Needless to say, if the place "cd" goes is not a worktree controlled
> by git, then "git apply" would not know where the top-level of the
> target tree is, so even though the input with the corrected command
> on the upstream side of the pipe tells it which file is being
> modified, it needs to be told with the proper -p<n> parameter how
> many leading levels to strip.

I think it's a common mistake to think of "git apply" as some sort of
magic extension of "patch" which can do anything that "patch" does and
more, and can be fed anything that "git diff" produces", figuring out by
itself what to do with it :)

Michael

  reply	other threads:[~2014-07-25  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24 13:29 `ab | (cd cd && git apply -)' fails with v2.0.0 Steffen Nurpmeso
2014-07-24 14:22 ` Michael J Gruber
2014-07-24 17:19   ` Junio C Hamano
2014-07-25  6:49     ` Michael J Gruber [this message]
2014-07-25 10:31       ` Steffen Nurpmeso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53D1FDE2.8030309@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sdaoden@yandex.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).