|
| 1 | +Patches produced by linkgit:git-format-patch[1] are inline. This means |
| 2 | +that the output from that command can lead to a different commit message |
| 3 | +when applied with linkgit:git-am[1]. It can also mean that the patch |
| 4 | +that is applied is not the same as the one that was generated, or that |
| 5 | +the patch application fails outright. |
| 6 | +ifdef::git-am[] |
| 7 | +See the <<discussion,DISCUSSION>> section above for the syntactic rules. |
| 8 | +endif::git-am[] |
| 9 | + |
| 10 | +ifndef::git-am[] |
| 11 | +Any line that is of the form: |
| 12 | + |
| 13 | +include::format-patch-end-of-commit-message.adoc[] |
| 14 | + |
| 15 | +will terminate the commit message and cause the patch machinery to start |
| 16 | +searching for patches to apply. |
| 17 | +endif::git-am[] |
| 18 | + |
| 19 | +Note that this is especially problematic for unindented diffs that occur |
| 20 | +in the commit message; the diff in the commit message might get applied |
| 21 | +along with the patch section, or the patch application machinery might |
| 22 | +trip up because the patch target doesn't apply. This could for example |
| 23 | +be caused by a diff in a GitHub Markdown code block. |
| 24 | + |
| 25 | +This loss of fidelity might be simple to notice if you are applying |
| 26 | +patches directly from a mailbox. However, changes originating from Git |
| 27 | +could be applied in bulk, in which case this would be much harder to |
| 28 | +notice. This could for example be a Linux distribution which uses patch |
| 29 | +files to apply changes on top of the commits from the upstream |
| 30 | +repositories. This goes to show that this behavior does not only impact |
| 31 | +email workflows. |
| 32 | + |
| 33 | +Given these limitations, one might be tempted to use a general-purpose |
| 34 | +utility like patch(1) instead. However, patch(1) will not only look for |
| 35 | +unindented diffs (like linkgit:git-am[1]) but will try to apply indented |
| 36 | +diffs as well. |
0 commit comments