{"thread":{"id":"31008","subject":"[PATCH] git-am: indicate where a failed patch is to be found.","startedAt":"2012-07-12T15:50:43Z","lastAt":"2012-07-13T23:02:30Z","messageCount":16,"participants":["Paul Gortmaker","Junio C Hamano","Jeff King","Nicolas Sebrecht"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"194967","messageId":"1342108243-8599-1-git-send-email-paul.gortmaker@windriver.com","threadId":"31008","inReplyTo":null,"subject":"[PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-12T15:50:43Z","receivedAt":"2012-07-12T15:50:43Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"If git am wasn't run with --reject, we assume the end user\nknows where to find the patch.  This is normally true for\na single patch, but if the user is processing a mbox with\nmany patches, they may not have a single broken out patch\nhandy.  So, provide a helpful hint as to where they can\nfind the patch to do the manual fixup before eventually\ncontinuing with \"git add ... ; git am -r\".\n\nSigned-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>\n\ndiff --git a/git-am.sh b/git-am.sh\nindex f8b7a0c..32e6ac0 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -854,7 +854,10 @@ did you forget to use 'git add'?\"\n \tfi\n \tif test $apply_status != 0\n \tthen\n-\t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n+\t\teval_gettextln \"Patch failed at $msgnum $FIRSTLINE\n+You can try running the following command:\n+   patch -p1 --dry-run < $dotest/patch\n+in order to possibly get more information on why it failed.\"\n \t\tstop_here_user_resolve $this\n \tfi\n \n-- \n1.7.9.7\n"},{"id":"194974","messageId":"7vhatcc1ql.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"1342108243-8599-1-git-send-email-paul.gortmaker@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-12T17:45:22Z","receivedAt":"2012-07-12T17:45:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> If git am wasn't run with --reject, we assume the end user\n> knows where to find the patch.  This is normally true for\n> a single patch,\n\nNot at all.  Whether it is a single or broken, the patch is fed to\nunderlying \"apply\" from an unadvertised place.\n\n> So, provide a helpful hint as to where they can\n> find the patch ...\n\nThis is OK, but you may want to give a way to squelch it once the\nuser learns where it is by following the usual \"advice.*\" thing.\n\n> ... to do the manual fixup before eventually\n> continuing with \"git add ... ; git am -r\".\n\nThis is _NOT_ fine, especially if you suggest \"patch\" the user may\nnot have, and more importantly does not have a clue why \"git apply\"\nrejected it (\"am\" does _not_ use \"patch\" at all).\n"},{"id":"194977","messageId":"4FFF1821.7030705@windriver.com","threadId":"31008","inReplyTo":"7vhatcc1ql.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-12T18:32:01Z","receivedAt":"2012-07-12T18:32:01Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"On 12-07-12 01:45 PM, Junio C Hamano wrote:\n> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n> \n>> If git am wasn't run with --reject, we assume the end user\n>> knows where to find the patch.  This is normally true for\n>> a single patch,\n> \n> Not at all.  Whether it is a single or broken, the patch is fed to\n> underlying \"apply\" from an unadvertised place.\n\nWhat I meant by this was the difference between:\n\n\tgit am 0001-some-standalone-single.patch\nvs.\n\tgit am mbox\n\nIn the 1st, the standalone patch is 100% clear and easy to access,\nbecause we really don't need/care about the unadvertised place.\n\nMaybe I should have said \"knows how to get at the single patch\"?\n\n> \n>> So, provide a helpful hint as to where they can\n>> find the patch ...\n> \n> This is OK, but you may want to give a way to squelch it once the\n> user learns where it is by following the usual \"advice.*\" thing.\n> \n>> ... to do the manual fixup before eventually\n>> continuing with \"git add ... ; git am -r\".\n> \n> This is _NOT_ fine, especially if you suggest \"patch\" the user may\n> not have, and more importantly does not have a clue why \"git apply\"\n> rejected it (\"am\" does _not_ use \"patch\" at all).\n\nI'm not 100% sure I'm following what part here is not OK.  If you\ncan help me understand that, I'll respin the change accordingly.\n\nIs it the assumption that the user will have the patch\ncommand in /usr/bin not OK, or that the message implies that\ngit is somehow using /usr/bin/patch is not OK?\n\nIn case it helps any, a brief summary of my workflow is this:\n\ngit am /tmp/mbox\n<some random fail halfway in the queue>\npatch -p1 --dry-run < .git/rebase-apply/patch\n# gauge status.  Is patch really invalid, or already applied?\n# already applied; \"git am --skip\"\n# no, if valid, but with minor issues, apply what we can.\npatch -p1 < .git/rebase-apply/patch\n# manually deal with rejects (typically with wiggle)\ngit add any_new_files\ngit add -u\ngit am -r\n\nPaul.\n--\n\n> \n> \n"},{"id":"194978","messageId":"7va9z4byl3.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"4FFF1821.7030705@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-12T18:53:28Z","receivedAt":"2012-07-12T18:53:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> On 12-07-12 01:45 PM, Junio C Hamano wrote:\n>> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n>> \n>>> If git am wasn't run with --reject, we assume the end user\n>>> knows where to find the patch.  This is normally true for\n>>> a single patch,\n>> \n>> Not at all.  Whether it is a single or broken, the patch is fed to\n>> underlying \"apply\" from an unadvertised place.\n>\n> What I meant by this was the difference between:\n>\n> \tgit am 0001-some-standalone-single.patch\n> vs.\n> \tgit am mbox\n>\n> In the 1st, the standalone patch is 100% clear and easy to access,\n> because we really don't need/care about the unadvertised place.\n\nIt does not matter at all that 0001-foo.patch only has a single\npatch.  If you are going to fix up the patch after you saw \"git am\"\nfailed, you will be fixing .git/rebase-apply/patch with your editor\nand re-run \"git am\" without arguments, at which point \"git am\" will\nnot look at your 0001-foo.patch file at all.\n\n>> This is _NOT_ fine, especially if you suggest \"patch\" the user may\n>> not have, and more importantly does not have a clue why \"git apply\"\n>> rejected it (\"am\" does _not_ use \"patch\" at all).\n>\n> I'm not 100% sure I'm following what part here is not OK.  If you\n> can help me understand that, I'll respin the change accordingly.\n\nDo not ever mention \"patch -p1\".  It is not the command that \"git\nam\" uses, and it is not what detected the breakage in the patch.\n\nThe command to guide the user to is \"git apply\".\n"},{"id":"194980","messageId":"4FFF2720.6090705@windriver.com","threadId":"31008","inReplyTo":"7va9z4byl3.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-12T19:36:00Z","receivedAt":"2012-07-12T19:36:00Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"On 12-07-12 02:53 PM, Junio C Hamano wrote:\n> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n> \n>> On 12-07-12 01:45 PM, Junio C Hamano wrote:\n>>> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n>>>\n>>>> If git am wasn't run with --reject, we assume the end user\n>>>> knows where to find the patch.  This is normally true for\n>>>> a single patch,\n>>>\n>>> Not at all.  Whether it is a single or broken, the patch is fed to\n>>> underlying \"apply\" from an unadvertised place.\n>>\n>> What I meant by this was the difference between:\n>>\n>> \tgit am 0001-some-standalone-single.patch\n>> vs.\n>> \tgit am mbox\n>>\n>> In the 1st, the standalone patch is 100% clear and easy to access,\n>> because we really don't need/care about the unadvertised place.\n> \n> It does not matter at all that 0001-foo.patch only has a single\n> patch.  If you are going to fix up the patch after you saw \"git am\"\n> failed, you will be fixing .git/rebase-apply/patch with your editor\n> and re-run \"git am\" without arguments, at which point \"git am\" will\n> not look at your 0001-foo.patch file at all.\n\nI think this is where our two thinking paths diverge.  You are\nsuggesting I edit and fix the patch.  Yes, occasionally I do\nthat, if it is a trivial context change.  But hand editing a\npatch is not for Joe Average, and gets very complicated in all\nbut the trivial cases.  So, what happens _way_ more often, is that\nI want to apply what can be applied, and deal with the rejects\non a one-by-one basis after that.  (BTW, this is not just me;\nthis patch came about from discussions with other kernel folks.)\n\n> \n>>> This is _NOT_ fine, especially if you suggest \"patch\" the user may\n>>> not have, and more importantly does not have a clue why \"git apply\"\n>>> rejected it (\"am\" does _not_ use \"patch\" at all).\n>>\n>> I'm not 100% sure I'm following what part here is not OK.  If you\n>> can help me understand that, I'll respin the change accordingly.\n> \n> Do not ever mention \"patch -p1\".  It is not the command that \"git\n> am\" uses, and it is not what detected the breakage in the patch.\n\nThis may be true, but it _is_ the command that I (and others) have\ndefaulted to using, if for no other reason than ignorance.\n\n> \n> The command to guide the user to is \"git apply\".\n> \n\nOK.  But I don't see a \"--dry-run\" equivalent -- and \"git apply --check\"\njust gives me a repeat of the same fail messages that \"git am\" did.\n\nWith \"patch -p1 --dry-run\"  I get information that immediately\nlets me see whether the patch is viable or not.  Is there a way\nto get a similar thing from \"git apply\" that I've overlooked?\n\nPaul.\n---\n"},{"id":"194981","messageId":"7v629sbvh8.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"4FFF2720.6090705@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-12T20:00:35Z","receivedAt":"2012-07-12T20:00:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n>>>> This is _NOT_ fine, especially if you suggest \"patch\" the user may\n>>>> not have, and more importantly does not have a clue why \"git apply\"\n>>>> rejected it (\"am\" does _not_ use \"patch\" at all).\n>>>\n>>> I'm not 100% sure I'm following what part here is not OK.  If you\n>>> can help me understand that, I'll respin the change accordingly.\n>> \n>> Do not ever mention \"patch -p1\".  It is not the command that \"git\n>> am\" uses, and it is not what detected the breakage in the patch.\n>\n> This may be true, but it _is_ the command that I (and others) have\n> defaulted to using, if for no other reason than ignorance.\n>> \n>> The command to guide the user to is \"git apply\".\n>\n> OK.  But I don't see a \"--dry-run\" equivalent -- and \"git apply --check\"\n> just gives me a repeat of the same fail messages that \"git am\" did.\n>\n> With \"patch -p1 --dry-run\"  I get information that immediately\n> lets me see whether the patch is viable or not.\n\nWhat do you mean by \"viable\"?  \n\nIndependent from the answer to that question...\n\nRunning \"git apply -p1\" would by definition give you the same\nfailure without --dry-run (because you know it already failed), no?\nThen you could ask for rejects or attempt to apply with reduced\ncontexts to \"git apply\" all without having to say --dry-run, as\nunapplicable change will not be applied.\n"},{"id":"194983","messageId":"20120712203339.GB13544@sigill.intra.peff.net","threadId":"31008","inReplyTo":"4FFF1821.7030705@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-07-12T20:33:39Z","receivedAt":"2012-07-12T20:33:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jul 12, 2012 at 02:32:01PM -0400, Paul Gortmaker wrote:\n\n> In case it helps any, a brief summary of my workflow is this:\n> \n> git am /tmp/mbox\n> <some random fail halfway in the queue>\n> patch -p1 --dry-run < .git/rebase-apply/patch\n> # gauge status.  Is patch really invalid, or already applied?\n> # already applied; \"git am --skip\"\n> # no, if valid, but with minor issues, apply what we can.\n> patch -p1 < .git/rebase-apply/patch\n> # manually deal with rejects (typically with wiggle)\n> git add any_new_files\n> git add -u\n> git am -r\n\nThis does not in any way address your patch, but you may find it\nhelpful. My usual next step after \"git am\" fails is to run \"git am -3\"\nand have it do a 3-way merge. This can sometimes resolve issues\nentirely, and when conflicts remain, they are placed in the file with\nthe usual conflict markers (and the conflicted files are marked in the\nindex, so you can even use \"git mergetool\" to help you run an external\ntool like xxdiff).\n\n-Peff\n"},{"id":"194986","messageId":"7vobnkadsw.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"4FFF2720.6090705@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-12T21:07:43Z","receivedAt":"2012-07-12T21:07:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> I think this is where our two thinking paths diverge.  You are\n> suggesting I edit and fix the patch.  Yes, occasionally I do\n> that, if it is a trivial context change.  But hand editing a\n> patch is not for Joe Average, and gets very complicated in all\n> but the trivial cases.\n\nIn your patch, you do not special case and refrain from giving the\nlocation of the patchfile when there is only one patch in the input,\nso the above does not matter anyway.\n\nThe patch does two unrelated things: reveal the location of the\nactual patchfile that failed to apply which was so far kept sekrit,\nand tell the user what to do with it.\n\nBecause a user who _wants to_ use a patch, once she knows where it\nis, would know her favorite way of working with it (be it by editing\nit and reapplying, running \"git apply\" with --reject or reduced\ncontext lines, or running \"patch\"), an advice on _what_ to do is of\nsecondary importance between the two.  Perhaps we can postpone the\ndiscussion on that and first update the code to tell _where_ the\npatch is to the user?  That would be an improvement from the current\ncodebase no matter what your faviourite workflow is.\n"},{"id":"194987","messageId":"20120712211835.GA858@vidovic","threadId":"31008","inReplyTo":"7va9z4byl3.fsf@alter.siamese.dyndns.org","subject":"[PATCH] Re: git-am: indicate where a failed patch is to be found.","fromName":"Nicolas Sebrecht","fromEmail":"nicolas.s.dev@gmx.fr","sentAt":"2012-07-12T21:18:35Z","receivedAt":"2012-07-12T21:18:35Z","isPatch":true,"sender":{"key":"nicolas.s.dev@gmx.fr","avatar":null},"body":"The 12/07/12, Junio C Hamano wrote:\n\n> It does not matter at all that 0001-foo.patch only has a single\n> patch.  If you are going to fix up the patch after you saw \"git am\"\n> failed, you will be fixing .git/rebase-apply/patch with your editor\n> and re-run \"git am\" without arguments, at which point \"git am\" will\n> not look at your 0001-foo.patch file at all.\n\nHugh! Didn't know that.\n\nIs it actually expected from users to manually edit\n.git/rebase-apply/patch path? I can't find any reference about that in\nthe documentation and it really sounds like interfering with the git\ninternals.\n\nShouldn't git-am/git-rebase expose this to the user (I'm thinking about\nsomething like\n\n  git am --edit-offending-patch\n  git am --fix-patch\n\n)?\n\n-- \nNicolas Sebrecht\n"},{"id":"194988","messageId":"7vfw8wablm.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"20120712211835.GA858@vidovic","subject":"Re: [PATCH] Re: git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-12T21:55:17Z","receivedAt":"2012-07-12T21:55:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nicolas Sebrecht <nicolas.s.dev@gmx.fr> writes:\n\n> The 12/07/12, Junio C Hamano wrote:\n>\n>> It does not matter at all that 0001-foo.patch only has a single\n>> patch.  If you are going to fix up the patch after you saw \"git am\"\n>> failed, you will be fixing .git/rebase-apply/patch with your editor\n>> and re-run \"git am\" without arguments, at which point \"git am\" will\n>> not look at your 0001-foo.patch file at all.\n>\n> Hugh! Didn't know that.\n>\n> Is it actually expected from users to manually edit\n> .git/rebase-apply/patch path? I can't find any reference about that in\n> the documentation and it really sounds like interfering with the git\n> internals.\n>\n> Shouldn't git-am/git-rebase expose this to the user (I'm thinking about\n> something like\n>\n>   git am --edit-offending-patch\n>   git am --fix-patch\n\nI doubt it would be very useful.  As Paul says, it is a powerful way\nto work, but it is not for everybody, and more importantly, it is\nnot the only way to work with the patch, once the user knows where\nit is.\n\nThe first problem before any of that is that we didn't tell the user\nwhere the patch is.  You can re-run \"git am\" with different options\nlike reject, \"-3\", and/or with a reduced context and many cases are\nhandled without having to know where the patch is at all, but if the\nuser starts wanting to know where the patch is because she wants to\ndo things beyond that, we should just tell her where it is, instead\nof adding a yet another option to run an editor on it, still without\ntelling her where it is.\n"},{"id":"195012","messageId":"1342194690-31578-1-git-send-email-paul.gortmaker@windriver.com","threadId":"31008","inReplyTo":"7vobnkadsw.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-13T15:51:30Z","receivedAt":"2012-07-13T15:51:30Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"If git am fails to apply something, the end user may need\nto know where to find the patch.  This is normally known for\na single patch, but if the user is processing a mbox with\nmany patches, they may not have a single broken out patch\nhandy.  So, provide a helpful hint as to where they can\nfind the patch to do some sort of manual fixup, if we\nare processing a mbox with more than one patch in it.\n\nSigned-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>\n---\n[v2: drop text suggesting what to do with failed patch; only\n emit the help text if we are processing mbox with multi patches]\n\n git-am.sh |    5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex f8b7a0c..20b3b73 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -855,6 +855,11 @@ did you forget to use 'git add'?\"\n \tif test $apply_status != 0\n \tthen\n \t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n+\t\tif test $patch_format = mbox && test \"$last\" -ne \"1\"\n+\t\tthen\n+\t\t\teval_gettextln \"You can find the copy of the patch that failed here:\n+   $dotest/patch\"\n+\t\tfi\n \t\tstop_here_user_resolve $this\n \tfi\n \n-- \n1.7.9.7\n"},{"id":"195015","messageId":"50005D8E.1020407@windriver.com","threadId":"31008","inReplyTo":"7v629sbvh8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-13T17:40:30Z","receivedAt":"2012-07-13T17:40:30Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"On 12-07-12 04:00 PM, Junio C Hamano wrote:\n> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n> \n>>>>> This is _NOT_ fine, especially if you suggest \"patch\" the user may\n>>>>> not have, and more importantly does not have a clue why \"git apply\"\n>>>>> rejected it (\"am\" does _not_ use \"patch\" at all).\n>>>>\n>>>> I'm not 100% sure I'm following what part here is not OK.  If you\n>>>> can help me understand that, I'll respin the change accordingly.\n>>>\n>>> Do not ever mention \"patch -p1\".  It is not the command that \"git\n>>> am\" uses, and it is not what detected the breakage in the patch.\n>>\n>> This may be true, but it _is_ the command that I (and others) have\n>> defaulted to using, if for no other reason than ignorance.\n>>>\n>>> The command to guide the user to is \"git apply\".\n>>\n>> OK.  But I don't see a \"--dry-run\" equivalent -- and \"git apply --check\"\n>> just gives me a repeat of the same fail messages that \"git am\" did.\n>>\n>> With \"patch -p1 --dry-run\"  I get information that immediately\n>> lets me see whether the patch is viable or not.\n> \n> What do you mean by \"viable\"?  \n\nSorry, that description was a bit context free.  Two typical cases:\n\n1) applying a series of commits (e.g. preempt RT feature) to a newer\nbaseline. Some of those commits may have been upstreamed and now\npresent in mainline.  The \"git am\" failure doesn't really hint that\n\"already applied\" may be the case -- e.g. consider and compare the\noutput when we extract and then intentionally try to re-apply something\nalready in tree, created with:\n\n-------------\n$git format-patch 50fb31cf~..50fb31cf\n0001-tty-hvc_opal-Fix-debug-function-name.patch\n-------------\n\nWith \"git am\":\n--------------------------\n$git am 0001-tty-hvc_opal-Fix-debug-function-name.patch\nApplying: tty/hvc_opal: Fix debug function name\nerror: patch failed: drivers/tty/hvc/hvc_opal.c:401\nerror: drivers/tty/hvc/hvc_opal.c: patch does not apply\nPatch failed at 0001 tty/hvc_opal: Fix debug function name\nWhen you have resolved this problem run \"git am --resolved\".\nIf you would prefer to skip this patch, instead run \"git am --skip\".\nTo restore the original branch and stop patching run \"git am --abort\".\n---------------------------\n\n...versus \n\n---------------------------\n$patch -p1 --dry-run < 0001-tty-hvc_opal-Fix-debug-function-name.patch \npatching file drivers/tty/hvc/hvc_opal.c\nReversed (or previously applied) patch detected!  Assume -R? [n] \nApply anyway? [n] \nSkipping patch.\n1 out of 1 hunk ignored -- saving rejects to file drivers/tty/hvc/hvc_opal.c.rej\n---------------------------\n\n...versus\n\n---------------------------\n$git apply -p1 0001-tty-hvc_opal-Fix-debug-function-name.patch\nerror: patch failed: drivers/tty/hvc/hvc_opal.c:401\nerror: drivers/tty/hvc/hvc_opal.c: patch does not apply\n---------------------------\n\nMaybe there is an easy way to teach git am/apply to detect \"previously\napplied\" in a way similar to patch?  The closest I could come to that\nwas \"git apply --check -R ...\" and seeing what it said (or didn't say).\n\n2) In maintaining linux stable releases (esp older ones), the dry-run\noutput, if say it says something like 23/30 chunks failed, it tells me\nthat the underlying baseline has probably changed too much for a simple\nbackport.  But if only 1/30 chunks fail or similar, I'll simply proceed\nsince the backport is viable and likely trivial.\n\nPaul.\n--\n\n> \n> Independent from the answer to that question...\n> \n> Running \"git apply -p1\" would by definition give you the same\n> failure without --dry-run (because you know it already failed), no?\n> Then you could ask for rejects or attempt to apply with reduced\n> contexts to \"git apply\" all without having to say --dry-run, as\n> unapplicable change will not be applied.\n> \n"},{"id":"195018","messageId":"7vtxxb8rjo.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"50005D8E.1020407@windriver.com","subject":"Re: [PATCH] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-13T18:06:03Z","receivedAt":"2012-07-13T18:06:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> Sorry, that description was a bit context free.  Two typical cases:\n>\n> 1) applying a series of commits (e.g. preempt RT feature) to a newer\n> baseline. Some of those commits may have been upstreamed and now\n> present in mainline.  The \"git am\" failure doesn't really hint that\n> \"already applied\" may be the case -- e.g. consider and compare the\n> output when we extract and then intentionally try to re-apply something\n> already in tree, created with:\n>\n> -------------\n> $git format-patch 50fb31cf~..50fb31cf\n> 0001-tty-hvc_opal-Fix-debug-function-name.patch\n> -------------\n>\n> With \"git am\":\n> --------------------------\n> $git am 0001-tty-hvc_opal-Fix-debug-function-name.patch\n> Applying: tty/hvc_opal: Fix debug function name\n> error: patch failed: drivers/tty/hvc/hvc_opal.c:401\n> error: drivers/tty/hvc/hvc_opal.c: patch does not apply\n> Patch failed at 0001 tty/hvc_opal: Fix debug function name\n> When you have resolved this problem run \"git am --resolved\".\n> If you would prefer to skip this patch, instead run \"git am --skip\".\n> To restore the original branch and stop patching run \"git am --abort\".\n> ---------------------------\n>\n> ...versus \n>\n> ---------------------------\n> $patch -p1 --dry-run < 0001-tty-hvc_opal-Fix-debug-function-name.patch \n> patching file drivers/tty/hvc/hvc_opal.c\n> Reversed (or previously applied) patch detected!  Assume -R? [n] \n> Apply anyway? [n] \n> Skipping patch.\n> 1 out of 1 hunk ignored -- saving rejects to file drivers/tty/hvc/hvc_opal.c.rej\n> ---------------------------\n\n\"git am -3\" will give you a message \"already applied\" and moves on,\nor if an already applied stuff is similar but not different would\nstop with conflict, or fail butd the latter two cases GNU patch\nwould not say \"reversed\", so \"am -3\" would be a win 2 out of 3 cases\nand the remaining 1 out of 3 case would be a tie.\n\n> 2) In maintaining linux stable releases (esp older ones), the dry-run\n> output, if say it says something like 23/30 chunks failed, it tells me\n> that the underlying baseline has probably changed too much for a simple\n> backport.  But if only 1/30 chunks fail or similar, I'll simply proceed\n> since the backport is viable and likely trivial.\n\nPerhaps \"git apply\" when stops upon unapplicable patch may want to\nbe improved to give more detailed diagnostics (I think it stops upon\nfirst hunk per each file that is touched---it may be able to keep\ngoing and see if other hunks might apply).  This is in \"patches\nwelcome\" category ;-).\n"},{"id":"195025","messageId":"7vipdr8mch.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"1342194690-31578-1-git-send-email-paul.gortmaker@windriver.com","subject":"Re: [PATCH v2] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-13T19:58:22Z","receivedAt":"2012-07-13T19:58:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> If git am fails to apply something, the end user may need\n> to know where to find the patch.  This is normally known for\n> a single patch, but if the user is processing a mbox with\n> many patches, they may not have a single broken out patch\n> handy.  So, provide a helpful hint as to where they can\n> find the patch to do some sort of manual fixup, if we\n> are processing a mbox with more than one patch in it.\n\nI would rather see this done even for a single patch mbox.  The\npatch that was fed to \"git apply\" by \"git am\" and failed to apply is\nthat one, not the one in the mbox you gave \"git am\".  The latter may\nbe ungrokkable with GNU patch or \"git apply\", if the original was\nsent in Quoted-Printable and such MIME funnies, which is the whole\npoint of having a separate file there for \"git am\", instead of\nfeeding the original.\n\nI am not sure if we should limit $patch_format to mbox, but I think\nshowing this unconditionally regardless of mbox/stgit/hg will teach\nthe user only one location to remember, so perhaps like this?\n\n Documentation/config.txt | 3 +++\n git-am.sh                | 4 ++--\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 0e1168c..b1f0a75 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -143,6 +143,9 @@ advice.*::\n \t\tAdvice shown when you used linkgit:git-checkout[1] to\n \t\tmove to the detach HEAD state, to instruct how to create\n \t\ta local branch after the fact.\n+\tamWorkDir::\n+\t\tAdvice that shows the location of the patch file when\n+\t\tlinkgit:git-am[1] fails to apply it.\n --\n \n core.fileMode::\ndiff --git a/git-am.sh b/git-am.sh\nindex dc48f87..f1ae932 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -834,9 +834,9 @@ did you forget to use 'git add'?\"\n \tif test $apply_status != 0\n \tthen\n \t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n-\t\tif test $patch_format = mbox && test \"$last\" -ne \"1\"\n+\t\tif test \"$(git config --bool advice.amworkdir)\" != false\n \t\tthen\n-\t\t\teval_gettextln \"You can find the copy of the patch that failed here:\n+\t\t\teval_gettextln \"The copy of the patch that failed is found in:\n    $dotest/patch\"\n \t\tfi\n \t\tstop_here_user_resolve $this\n"},{"id":"195030","messageId":"5000A52B.3090003@windriver.com","threadId":"31008","inReplyTo":"7vipdr8mch.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] git-am: indicate where a failed patch is to be found.","fromName":"Paul Gortmaker","fromEmail":"paul.gortmaker@windriver.com","sentAt":"2012-07-13T22:46:03Z","receivedAt":"2012-07-13T22:46:03Z","isPatch":true,"sender":{"key":"paul.gortmaker@windriver.com","avatar":null},"body":"On 12-07-13 03:58 PM, Junio C Hamano wrote:\n> Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n> \n>> If git am fails to apply something, the end user may need\n>> to know where to find the patch.  This is normally known for\n>> a single patch, but if the user is processing a mbox with\n>> many patches, they may not have a single broken out patch\n>> handy.  So, provide a helpful hint as to where they can\n>> find the patch to do some sort of manual fixup, if we\n>> are processing a mbox with more than one patch in it.\n> \n> I would rather see this done even for a single patch mbox.  The\n\nOK, I got the opposite impression from your prev. mail when\nyou mentioned that I hadn't limited the message output at all.\n\nI'm fine with the changes you've proposed below, and can squash that\ninto a v3 and resend again.\n\nPaul.\n--\n\n> patch that was fed to \"git apply\" by \"git am\" and failed to apply is\n> that one, not the one in the mbox you gave \"git am\".  The latter may\n> be ungrokkable with GNU patch or \"git apply\", if the original was\n> sent in Quoted-Printable and such MIME funnies, which is the whole\n> point of having a separate file there for \"git am\", instead of\n> feeding the original.\n> \n> I am not sure if we should limit $patch_format to mbox, but I think\n> showing this unconditionally regardless of mbox/stgit/hg will teach\n> the user only one location to remember, so perhaps like this?\n> \n>  Documentation/config.txt | 3 +++\n>  git-am.sh                | 4 ++--\n>  2 files changed, 5 insertions(+), 2 deletions(-)\n> \n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 0e1168c..b1f0a75 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -143,6 +143,9 @@ advice.*::\n>  \t\tAdvice shown when you used linkgit:git-checkout[1] to\n>  \t\tmove to the detach HEAD state, to instruct how to create\n>  \t\ta local branch after the fact.\n> +\tamWorkDir::\n> +\t\tAdvice that shows the location of the patch file when\n> +\t\tlinkgit:git-am[1] fails to apply it.\n>  --\n>  \n>  core.fileMode::\n> diff --git a/git-am.sh b/git-am.sh\n> index dc48f87..f1ae932 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -834,9 +834,9 @@ did you forget to use 'git add'?\"\n>  \tif test $apply_status != 0\n>  \tthen\n>  \t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n> -\t\tif test $patch_format = mbox && test \"$last\" -ne \"1\"\n> +\t\tif test \"$(git config --bool advice.amworkdir)\" != false\n>  \t\tthen\n> -\t\t\teval_gettextln \"You can find the copy of the patch that failed here:\n> +\t\t\teval_gettextln \"The copy of the patch that failed is found in:\n>     $dotest/patch\"\n>  \t\tfi\n>  \t\tstop_here_user_resolve $this\n> \n"},{"id":"195032","messageId":"7vobnj6z95.fsf@alter.siamese.dyndns.org","threadId":"31008","inReplyTo":"5000A52B.3090003@windriver.com","subject":"Re: [PATCH v2] git-am: indicate where a failed patch is to be found.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-13T23:02:30Z","receivedAt":"2012-07-13T23:02:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Gortmaker <paul.gortmaker@windriver.com> writes:\n\n> I'm fine with the changes you've proposed below,...\n\nHere is what I committed for today's integration run.  Will be\npushed out on 'pu'.\n\nThanks.\n\n-- >8 --\nFrom: Paul Gortmaker <paul.gortmaker@windriver.com>\nDate: Fri, 13 Jul 2012 11:51:30 -0400\nSubject: [PATCH] am: indicate where a failed patch is to be found\n\nIf \"git am\" fails to apply something, the end user may need to know\nwhere to find the patch that failed to apply, so that the user can\ndo other things (e.g. trying \"GNU patch\" on it, running \"diffstat\"\nto see what it tried to change, etc.)  The input to \"am\" may have\ncontained more than one patch, or the message may have been MIME\nencoded, and knowing what the user fed to \"am\" does not help very\nmuch for this purpose.\n\nAlso introduce advice.amworkdir configuration to allow people who\nlearned where to look to squelch this message.\n\nSigned-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/config.txt | 3 +++\n git-am.sh                | 5 +++++\n 2 files changed, 8 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 0e1168c..b1f0a75 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -143,6 +143,9 @@ advice.*::\n \t\tAdvice shown when you used linkgit:git-checkout[1] to\n \t\tmove to the detach HEAD state, to instruct how to create\n \t\ta local branch after the fact.\n+\tamWorkDir::\n+\t\tAdvice that shows the location of the patch file when\n+\t\tlinkgit:git-am[1] fails to apply it.\n --\n \n core.fileMode::\ndiff --git a/git-am.sh b/git-am.sh\nindex cb833e2..f1ae932 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -834,6 +834,11 @@ did you forget to use 'git add'?\"\n \tif test $apply_status != 0\n \tthen\n \t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n+\t\tif test \"$(git config --bool advice.amworkdir)\" != false\n+\t\tthen\n+\t\t\teval_gettextln \"The copy of the patch that failed is found in:\n+   $dotest/patch\"\n+\t\tfi\n \t\tstop_here_user_resolve $this\n \tfi\n \n-- \n1.7.11.2\n"}]}