{"thread":{"id":"55186","subject":"bug found in `git apply` sub-command","startedAt":"2021-02-22T19:25:35Z","lastAt":"2021-02-22T19:25:35Z","messageCount":1,"participants":["Mark Nicholson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"417484","messageId":"3d292e1d7c266eab456a5b9a0587efe702976533.camel@oracle.com","threadId":"55186","inReplyTo":null,"subject":"bug found in `git apply` sub-command","fromName":"Mark Nicholson","fromEmail":"mark.j.nicholson@oracle.com","sentAt":"2021-02-22T19:19:36Z","receivedAt":"2021-02-22T19:25:35Z","isPatch":false,"sender":{"key":"mark.j.nicholson@oracle.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n1. Clone torvalds/master\n\n2. Checkout a branch at this commit (the commit BEFORE the problematic one to\nstage the patch so it would work):\n        3e0de271fff77abb933f1b69c213854c3eda9125\n\n3. Get a 'git format-patch' of this commit:\n        ccf74128d66ce937876184ad55db2e0276af08d3\n        (this is the commit which causes the fault!)\n\n   I did:\n      git format-patch 3e0de271fff77a..ccf74128d66ce9\n   and it produced\n      0001-sched-topology-Assert-non-NUMA-topology-masks-don-t-.patch\n\n4. Try to `git apply` the format-patch generated:\n    git apply 0001-sched-topology-Assert-non-NUMA-topology-masks-don-t-.patch\n\n\n\n\nWhat did you expect to happen? (Expected behavior)\n\nI expected it to apply the patch cleanly.\nAFAICT, it is a VALID patch which is already committed to Linux.\n\n\n\nWhat happened instead? (Actual behavior)\n\n\nIt gives me the error message:\n\nerror: patch fragment without header at line 58: @@ -465,6 +465,9 @@ void\nupdate_siblings_masks(unsigned int cpuid)\n\n\n\nWhat's different between what you expected and what actually happened?\n\nIt shouldn't raise an error on applying this patch; its complaining about a\npatch-fragment _inside_ the message.\n\n\n\nAnything else you want to add:\n\nMy curiosity was raised since simply doing:\n\n   git am 0001-sched-topology-Assert-non-NUMA-topology-masks-don-t-.patch\n\napplies _exactly_ the same patch without any guff.\n\nI would _really_ expect `git am` and `git apply` to work in exactly the same way,\nexcept for the expected difference of the actual commit.  The \"patching\" part\nshould work identically.\n\nI tested some other behaviours and `git cherry-pick` of the offending commit\nworks fine. (Although, I suspect that this does not actually \"parse\" the commit\nmessage, so probably not and apples-to-apples comparison.)\n\n\nI looked at this patch and in the \"message\" section, it contains a patch-\nfragment.  Moreover, that patch-fragment is left-justified.\n\nA simple fix to avoid this problem is indenting the message-embedded patch-\nfragment by a couple spaces.\n\nIt appears that `git apply`, as it is parsing the message triggers on the patch-\nfragment INSIDE the message section.  Comparatively, `git am` does NOT trigger\nand both patches and commits it without issue.\n\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.30.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.15-172.current #1 SMP PREEMPT Fri Feb 12 16:35:57 UTC 2021\nx86_64\ncompiler info: gnuc: 9.3\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n\n"}]}