Skip to content

Commit e0d4827

Browse files
jrngitster
authored andcommitted
Documentation: describe the format of messages with inline patches
Add a DISCUSSION section to the "git format-patch" manual to encourage people to send patches in a form that can be applied by "git am" automatically. There are two such forms: 1. The default form in which most metadata goes in the mail header and the message body starts with the patch description; 2. The snipsnip form in which a message starts with pertinent discussion and ends with a patch after a "scissors" mark. The example requires QP encoding in the "Subject:" header intended for the mailer to give the reader a chance to reflect on that, rather than being startled by it later. By contrast, in-body "From:" and "Subject:" lines should be human-readable and not QP encoded. Inspired-by: Jim Meyering <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Improved-by: Junio C Hamano <[email protected]> Improved-by: Drew Northup <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 810cae5 commit e0d4827

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Documentation/git-format-patch.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,64 @@ attachments, and sign off patches with configuration variables.
229229
------------
230230

231231

232+
DISCUSSION
233+
----------
234+
235+
The patch produced by 'git format-patch' is in UNIX mailbox format,
236+
with a fixed "magic" time stamp to indicate that the file is output
237+
from format-patch rather than a real mailbox, like so:
238+
239+
------------
240+
From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001
241+
From: Tony Luck <[email protected]>
242+
Date: Tue, 13 Jul 2010 11:42:54 -0700
243+
Subject: [PATCH] =?UTF-8?q?[IA64]=20Put=20ia64=20config=20files=20on=20the=20?=
244+
=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20diet?=
245+
MIME-Version: 1.0
246+
Content-Type: text/plain; charset=UTF-8
247+
Content-Transfer-Encoding: 8bit
248+
249+
arch/arm config files were slimmed down using a python script
250+
(See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment)
251+
252+
Do the same for ia64 so we can have sleek & trim looking
253+
...
254+
------------
255+
256+
Typically it will be placed in a MUA's drafts folder, edited to add
257+
timely commentary that should not go in the changelog after the three
258+
dashes, and then sent as a message whose body, in our example, starts
259+
with "arch/arm config files were...". On the receiving end, readers
260+
can save interesting patches in a UNIX mailbox and apply them with
261+
linkgit:git-am[1].
262+
263+
When a patch is part of an ongoing discussion, the patch generated by
264+
'git format-patch' can be tweaked to take advantage of the 'git am
265+
--scissors' feature. After your response to the discussion comes a
266+
line that consists solely of "`-- >8 --`" (scissors and perforation),
267+
followed by the patch with unnecessary header fields removed:
268+
269+
------------
270+
...
271+
> So we should do such-and-such.
272+
273+
Makes sense to me. How about this patch?
274+
275+
-- >8 --
276+
Subject: [IA64] Put ia64 config files on the Uwe Kleine-König diet
277+
278+
arch/arm config files were slimmed down using a python script
279+
...
280+
------------
281+
282+
When sending a patch this way, most often you are sending your own
283+
patch, so in addition to the "`From $SHA1 $magic_timestamp`" marker you
284+
should omit `From:` and `Date:` lines from the patch file. The patch
285+
title is likely to be different from the subject of the discussion the
286+
patch is in response to, so it is likely that you would want to keep
287+
the Subject: line, like the example above.
288+
289+
232290
EXAMPLES
233291
--------
234292

0 commit comments

Comments
 (0)