{"thread":{"id":"37204","subject":"`ab | (cd cd && git apply -)' fails with v2.0.0","startedAt":"2014-07-24T13:29:45Z","lastAt":"2014-07-25T10:31:51Z","messageCount":5,"participants":["Steffen Nurpmeso","Michael J Gruber","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"246638","messageId":"20140724142945.iERQ798d%sdaoden@yandex.com","threadId":"37204","inReplyTo":null,"subject":"`ab | (cd cd && git apply -)' fails with v2.0.0","fromName":"Steffen Nurpmeso","fromEmail":"sdaoden@yandex.com","sentAt":"2014-07-24T13:29:45Z","receivedAt":"2014-07-24T13:29:45Z","isPatch":false,"sender":{"key":"sdaoden@yandex.com","avatar":null},"body":"Hello (again, psssssst, after a long time),\n\nit happened yesterday that i needed to do\n\n  $ git diff HEAD:FILE COMMIT:SAME-FILE |\n  > (cd src && git apply -) \n\nbut found that didn't work with v2.0.0 (silently succeeds?, doing\nnothing).  It works without the subshell and the cd(1); i had to\nuse `(cd src && patch -p2)' instead to keep in going.\nJust in case that is not known yet (i've updated my git(1) repo,\nbut in the 1466 commits in between nothing sprung into my eye\nregarding apply, and a Gmane search didn't, too).\nNo need to Cc: me, please just fix it; thank you.\nCiao,\n\n--steffen\n"},{"id":"246641","messageId":"53D116B9.3050809@drmicha.warpmail.net","threadId":"37204","inReplyTo":"20140724142945.iERQ798d%sdaoden@yandex.com","subject":"Re: `ab | (cd cd && git apply -)' fails with v2.0.0","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2014-07-24T14:22:49Z","receivedAt":"2014-07-24T14:22:49Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Steffen Nurpmeso venit, vidit, dixit 24.07.2014 15:29:\n> Hello (again, psssssst, after a long time),\n> \n> it happened yesterday that i needed to do\n> \n>   $ git diff HEAD:FILE COMMIT:SAME-FILE |\n>   > (cd src && git apply -) \n> \n> but found that didn't work with v2.0.0 (silently succeeds?, doing\n> nothing).  It works without the subshell and the cd(1); i had to\n> use `(cd src && patch -p2)' instead to keep in going.\n> Just in case that is not known yet (i've updated my git(1) repo,\n> but in the 1466 commits in between nothing sprung into my eye\n> regarding apply, and a Gmane search didn't, too).\n> No need to Cc: me, please just fix it; thank you.\n> Ciao,\n> \n> --steffen\n> \n\nAh little more context would help. Are you diffing files in the subdir\nsrc, or a file at the root which happens to be present in the subdir src\nas well?\n\nMichael\n"},{"id":"246652","messageId":"xmqqegxaad3r.fsf@gitster.dls.corp.google.com","threadId":"37204","inReplyTo":"53D116B9.3050809@drmicha.warpmail.net","subject":"Re: `ab | (cd cd && git apply -)' fails with v2.0.0","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-24T17:19:36Z","receivedAt":"2014-07-24T17:19:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Steffen Nurpmeso venit, vidit, dixit 24.07.2014 15:29:\n>> Hello (again, psssssst, after a long time),\n>> \n>> it happened yesterday that i needed to do\n>> \n>>   $ git diff HEAD:FILE COMMIT:SAME-FILE |\n>>   > (cd src && git apply -) \n>> ...\n>\n> Ah little more context would help. Are you diffing files in the subdir\n> src, or a file at the root which happens to be present in the subdir src\n> as well?\n\nAs the <treeish>:<path> form is not meant to produce \"git apply\"\napplicable patch in the first place, I am not sure what the OP is\ntrying to achieve in the first place.  Not just \"how many leading\nlevels to strip?\" but \"which file is being modified?\" does not\nappear in a usable form.  For example, here is what you would see:\n\n    $ git diff HEAD:GIT-VERSION-GEN maint:GIT-VERSION-GEN\n    diff --git a/HEAD:GIT-VERSION-GEN b/maint:GIT-VERSION-GEN\n    index 40adbf7..0d1a86c 100755\n    --- a/HEAD:GIT-VERSION-GEN\n    +++ b/maint:GIT-VERSION-GEN\n    @@ -1,7 +1,7 @@\n    ...\n\nand neither \"HEAD:GIT-VERSION-GEN\" nor \"maint:GIT-VERSION-GEN\" is\nthe file being modified (\"GIT-VERSION-GEN\" is).\n\nI would understand if the upstream of the pipe were\n\n    $ git diff HEAD maint -- GIT-VERSION-GEN | ...\n\nthough.\n\nNeedless to say, if the place \"cd\" goes is not a worktree controlled\nby git, then \"git apply\" would not know where the top-level of the\ntarget tree is, so even though the input with the corrected command\non the upstream side of the pipe tells it which file is being\nmodified, it needs to be told with the proper -p<n> parameter how\nmany leading levels to strip.\n"},{"id":"246680","messageId":"53D1FDE2.8030309@drmicha.warpmail.net","threadId":"37204","inReplyTo":"xmqqegxaad3r.fsf@gitster.dls.corp.google.com","subject":"Re: `ab | (cd cd && git apply -)' fails with v2.0.0","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2014-07-25T06:49:06Z","receivedAt":"2014-07-25T06:49:06Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 24.07.2014 19:19:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> Steffen Nurpmeso venit, vidit, dixit 24.07.2014 15:29:\n>>> Hello (again, psssssst, after a long time),\n>>>\n>>> it happened yesterday that i needed to do\n>>>\n>>>   $ git diff HEAD:FILE COMMIT:SAME-FILE |\n>>>   > (cd src && git apply -) \n>>> ...\n>>\n>> Ah little more context would help. Are you diffing files in the subdir\n>> src, or a file at the root which happens to be present in the subdir src\n>> as well?\n> \n> As the <treeish>:<path> form is not meant to produce \"git apply\"\n> applicable patch in the first place, I am not sure what the OP is\n> trying to achieve in the first place.  Not just \"how many leading\n> levels to strip?\" but \"which file is being modified?\" does not\n> appear in a usable form.  For example, here is what you would see:\n> \n>     $ git diff HEAD:GIT-VERSION-GEN maint:GIT-VERSION-GEN\n>     diff --git a/HEAD:GIT-VERSION-GEN b/maint:GIT-VERSION-GEN\n>     index 40adbf7..0d1a86c 100755\n>     --- a/HEAD:GIT-VERSION-GEN\n>     +++ b/maint:GIT-VERSION-GEN\n>     @@ -1,7 +1,7 @@\n>     ...\n> \n> and neither \"HEAD:GIT-VERSION-GEN\" nor \"maint:GIT-VERSION-GEN\" is\n> the file being modified (\"GIT-VERSION-GEN\" is).\n\nI thought \"git apply\" knows how to strip the rev part.\n\n> I would understand if the upstream of the pipe were\n> \n>     $ git diff HEAD maint -- GIT-VERSION-GEN | ...\n> \n> though.\n> \n> Needless to say, if the place \"cd\" goes is not a worktree controlled\n> by git, then \"git apply\" would not know where the top-level of the\n> target tree is, so even though the input with the corrected command\n> on the upstream side of the pipe tells it which file is being\n> modified, it needs to be told with the proper -p<n> parameter how\n> many leading levels to strip.\n\nI think it's a common mistake to think of \"git apply\" as some sort of\nmagic extension of \"patch\" which can do anything that \"patch\" does and\nmore, and can be fed anything that \"git diff\" produces\", figuring out by\nitself what to do with it :)\n\nMichael\n"},{"id":"246684","messageId":"20140725113151.1k4Xqb6C%sdaoden@yandex.com","threadId":"37204","inReplyTo":"53D1FDE2.8030309@drmicha.warpmail.net","subject":"Re: `ab | (cd cd && git apply -)' fails with v2.0.0","fromName":"Steffen Nurpmeso","fromEmail":"sdaoden@yandex.com","sentAt":"2014-07-25T10:31:51Z","receivedAt":"2014-07-25T10:31:51Z","isPatch":false,"sender":{"key":"sdaoden@yandex.com","avatar":null},"body":"Hello and good morning,\n\nMichael J Gruber <git@drmicha.warpmail.net> wrote:\n |Junio C Hamano venit, vidit, dixit 24.07.2014 19:19:\n |> Michael J Gruber <git@drmicha.warpmail.net> writes:\n |>> Steffen Nurpmeso venit, vidit, dixit 24.07.2014 15:29:\n |>>> Hello (again, psssssst, after a long time),\n |>>>\n |>>> it happened yesterday that i needed to do\n |>>>\n |>>>   $ git diff HEAD:FILE COMMIT:SAME-FILE |\n |>>>> (cd src && git apply -) \n |>>> ...\n |>>\n |>> Ah little more context would help. Are you diffing files in the subdir\n |>> src, or a file at the root which happens to be present in the subdir src\n |>> as well?\n |> \n |> As the <treeish>:<path> form is not meant to produce \"git apply\"\n |> applicable patch in the first place, I am not sure what the OP is\n |> trying to achieve in the first place.  Not just \"how many leading\n |> levels to strip?\" but \"which file is being modified?\" does not\n |> appear in a usable form.  For example, here is what you would see:\n |> \n |>     $ git diff HEAD:GIT-VERSION-GEN maint:GIT-VERSION-GEN\n |>     diff --git a/HEAD:GIT-VERSION-GEN b/maint:GIT-VERSION-GEN\n |>     index 40adbf7..0d1a86c 100755\n |>     --- a/HEAD:GIT-VERSION-GEN\n |>     +++ b/maint:GIT-VERSION-GEN\n |>     @@ -1,7 +1,7 @@\n |>     ...\n |> \n |> and neither \"HEAD:GIT-VERSION-GEN\" nor \"maint:GIT-VERSION-GEN\" is\n |> the file being modified (\"GIT-VERSION-GEN\" is).\n |\n |I thought \"git apply\" knows how to strip the rev part.\n\nThat would brighten the sky of the glorious future.  Perfect!\n\n |> I would understand if the upstream of the pipe were\n |> \n |>     $ git diff HEAD maint -- GIT-VERSION-GEN | ...\n |> \n |> though.\n\nYes, in this case it applies the patch.\n\n |> Needless to say, if the place \"cd\" goes is not a worktree controlled\n |> by git, then \"git apply\" would not know where the top-level of the\n |> target tree is, so even though the input with the corrected command\n |> on the upstream side of the pipe tells it which file is being\n |> modified, it needs to be told with the proper -p<n> parameter how\n |> many leading levels to strip.\n |\n |I think it's a common mistake to think of \"git apply\" as some sort of\n |magic extension of \"patch\" which can do anything that \"patch\" does and\n |more, and can be fed anything that \"git diff\" produces\", figuring out by\n |itself what to do with it :)\n\nThis was indeed my mistake.\nBut regardless i think the current behaviour sucks:\n\n  ?0[steffen@sherwood x.git]$ git diff HEAD:XY 5d0d74:XY |\n  > (cd src && patch -p4)\n  can't find file to patch at input line 5\n  Perhaps you used the wrong -p or --strip option?\n  The text leading up to this was:\n  ?130[steffen@sherwood x.git]$ git diff HEAD:XY 5d0d74:XY |\n  > (cd src && git apply -p4)\n  ?0[steffen@sherwood x.git]$\n\nand\n\n  ?0[steffen@sherwood groff.git]$ git diff HEAD:XY 5d0d74:XY |\n  > (cd src && git apply -p2)\n  ?0[steffen@sherwood groff.git]$ git diff HEAD:XY 5d0d74:XY |\n  > (cd src && patch -p2)\n  patching file XY\n  ?0[steffen@sherwood groff.git]$ \n\nThe number after `?' is the exit status of the last command, btw.\nCiao (and yes, thanks a lot for git(1)!)\n\n--steffen\n"}]}