blob: 27304428a12ce9d0ee46e10e3c63069b4677838a [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-format-patch(1)
2===================
3
4NAME
5----
Junio C Hamano01078922006-03-10 00:31:476git-format-patch - Prepare patches for e-mail submission
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
Junio C Hamanof4581102009-04-25 08:29:5912'git format-patch' [-k] [(-o|--output-directory) <dir> | --stdout]
Junio C Hamano1bbd0f42009-07-23 06:20:2913 [--no-thread | --thread[=<style>]]
Junio C Hamanof4581102009-04-25 08:29:5914 [(--attach|--inline)[=<boundary>] | --no-attach]
15 [-s | --signoff]
Junio C Hamano89a57342010-06-22 23:22:5516 [--signature=<signature> | --no-signature]
Junio C Hamanoc8c398a2014-06-16 21:14:0517 [--signature-file=<file>]
Junio C Hamano24bc09a2008-02-28 00:27:4418 [-n | --numbered | -N | --no-numbered]
19 [--start-number <n>] [--numbered-files]
20 [--in-reply-to=Message-Id] [--suffix=.<sfx>]
21 [--ignore-if-in-upstream]
Junio C Hamanoad70bf02016-09-26 23:44:2722 [--rfc] [--subject-prefix=Subject-Prefix]
23 [(--reroll-count|-v) <n>]
Junio C Hamanoea90ab32010-03-15 20:32:5524 [--to=<email>] [--cc=<email>]
Junio C Hamanoea3b7522013-04-18 19:37:5325 [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]
Junio C Hamano980e61e2018-09-17 22:45:5226 [--interdiff=<previous>]
27 [--range-diff=<previous> [--creation-factor=<percent>]]
Junio C Hamanoa4ff7292017-08-23 21:56:4328 [--progress]
Junio C Hamanof4581102009-04-25 08:29:5929 [<common diff options>]
Junio C Hamano7d9e9bd2007-08-29 07:31:4730 [ <since> | <revision range> ]
Junio C Hamano1a4e8412005-12-27 08:17:2331
32DESCRIPTION
33-----------
Junio C Hamano341071d2006-06-04 07:24:4834
Junio C Hamano7d9e9bd2007-08-29 07:31:4735Prepare each commit with its patch in
Junio C Hamano341071d2006-06-04 07:24:4836one file per commit, formatted to resemble UNIX mailbox format.
Junio C Hamano341071d2006-06-04 07:24:4837The output of this command is convenient for e-mail submission or
Junio C Hamano1aa40d22010-01-21 17:46:4338for use with 'git am'.
Junio C Hamano1a4e8412005-12-27 08:17:2339
Junio C Hamano7d9e9bd2007-08-29 07:31:4740There are two ways to specify which commits to operate on.
41
421. A single commit, <since>, specifies that the commits leading
43 to the tip of the current branch that are not in the history
44 that leads to the <since> to be output.
45
462. Generic <revision range> expression (see "SPECIFYING
Junio C Hamanoc27b7332010-10-14 04:37:2847 REVISIONS" section in linkgit:gitrevisions[7]) means the
Junio C Hamano7d9e9bd2007-08-29 07:31:4748 commits in the specified range.
49
Junio C Hamano9572e922009-04-02 06:52:0350The first rule takes precedence in the case of a single <commit>. To
51apply the second rule, i.e., format everything since the beginning of
Junio C Hamanoccb82522018-05-08 07:52:0952history up until <commit>, use the `--root` option: `git format-patch
Junio C Hamanob76a6862012-05-02 22:02:4653--root <commit>`. If you want to format only <commit> itself, you
Junio C Hamano3b70d3c2009-11-21 17:37:3754can do this with `git format-patch -1 <commit>`.
Junio C Hamano7d9e9bd2007-08-29 07:31:4755
Junio C Hamano94cad1a2007-06-06 10:48:2556By default, each output file is numbered sequentially from 1, and uses the
Junio C Hamano341071d2006-06-04 07:24:4857first line of the commit message (massaged for pathname safety) as
Junio C Hamano3b70d3c2009-11-21 17:37:3758the filename. With the `--numbered-files` option, the output file names
Junio C Hamano94cad1a2007-06-06 10:48:2559will only be numbers, without the first line of the commit appended.
60The names of the output files are printed to standard
Junio C Hamano3b70d3c2009-11-21 17:37:3761output, unless the `--stdout` option is specified.
Junio C Hamano38de0a22006-02-07 10:24:3562
Junio C Hamano3b70d3c2009-11-21 17:37:3763If `-o` is specified, output files are created in <dir>. Otherwise
Junio C Hamano289d7e82016-01-27 00:20:3864they are created in the current working directory. The default path
Junio C Hamano042f2142016-06-27 18:05:0565can be set with the `format.outputDirectory` configuration option.
Junio C Hamano289d7e82016-01-27 00:20:3866The `-o` option takes precedence over `format.outputDirectory`.
67To store patches in the current working directory even when
68`format.outputDirectory` points elsewhere, use `-o .`.
Junio C Hamano1a4e8412005-12-27 08:17:2369
Junio C Hamano281fd392012-09-17 23:57:4170By default, the subject of a single patch is "[PATCH] " followed by
71the concatenation of lines from the commit message up to the first blank
72line (see the DISCUSSION section of linkgit:git-commit[1]).
73
74When multiple patches are output, the subject prefix will instead be
75"[PATCH n/m] ". To force 1/1 to be added for a single patch, use `-n`.
76To omit patch numbers from the subject, use `-N`.
Junio C Hamano1a4e8412005-12-27 08:17:2377
Junio C Hamano3b70d3c2009-11-21 17:37:3778If given `--thread`, `git-format-patch` will generate `In-Reply-To` and
79`References` headers to make the second and subsequent patch mails appear
80as replies to the first mail; this also generates a `Message-Id` header to
Junio C Hamanof9ca97d2006-07-25 22:23:0981reference.
Junio C Hamano1a4e8412005-12-27 08:17:2382
83OPTIONS
84-------
Junio C Hamanoff979792007-11-16 10:11:3085:git-format-patch: 1
Junio C Hamano60f8aa82007-03-06 09:58:2686include::diff-options.txt[]
87
Junio C Hamanobb0f4042007-07-04 06:41:4088-<n>::
Junio C Hamano3b4609d2010-09-30 00:04:3489Prepare patches from the topmost <n> commits.
Junio C Hamanobb0f4042007-07-04 06:41:4090
Junio C Hamanoeb415992008-06-08 22:49:4791-o <dir>::
92--output-directory <dir>::
Junio C Hamano1a4e8412005-12-27 08:17:2393Use <dir> to store the resulting files, instead of the
Junio C Hamano1bab4b02006-06-06 21:58:3394current working directory.
Junio C Hamano1a4e8412005-12-27 08:17:2395
Junio C Hamanoeb415992008-06-08 22:49:4796-n::
97--numbered::
Junio C Hamano7d06a8a2008-10-20 05:42:3398Name output in '[PATCH n/m]' format, even with a single patch.
Junio C Hamano1a4e8412005-12-27 08:17:2399
Junio C Hamanoeb415992008-06-08 22:49:47100-N::
101--no-numbered::
Junio C Hamano8c5802d2007-11-15 00:13:36102Name output in '[PATCH]' format.
103
Junio C Hamano341071d2006-06-04 07:24:48104--start-number <n>::
105Start numbering the patches at <n> instead of 1.
106
Junio C Hamano94cad1a2007-06-06 10:48:25107--numbered-files::
108Output file names will be a simple number sequence
109without the default first line of the commit appended.
Junio C Hamano94cad1a2007-06-06 10:48:25110
Junio C Hamanoeb415992008-06-08 22:49:47111-k::
112--keep-subject::
Junio C Hamano1a4e8412005-12-27 08:17:23113Do not strip/add '[PATCH]' from the first line of the
114commit log message.
115
Junio C Hamanoeb415992008-06-08 22:49:47116-s::
117--signoff::
Junio C Hamano1a4e8412005-12-27 08:17:23118Add `Signed-off-by:` line to the commit message, using
119the committer identity of yourself.
Junio C Hamano4e6ba272016-01-20 23:23:19120See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamano1a4e8412005-12-27 08:17:23121
Junio C Hamano1a4e8412005-12-27 08:17:23122--stdout::
Junio C Hamano341071d2006-06-04 07:24:48123Print all commits to the standard output in mbox format,
124instead of creating a file for each one.
Junio C Hamano1a4e8412005-12-27 08:17:23125
Junio C Hamanoc51fede2007-03-12 07:29:20126--attach[=<boundary>]::
127Create multipart/mixed attachment, the first part of
128which is the commit message and the patch itself in the
Junio C Hamano3b70d3c2009-11-21 17:37:37129second part, with `Content-Disposition: attachment`.
Junio C Hamanoc51fede2007-03-12 07:29:20130
Junio C Hamano0a235222009-03-06 08:21:09131--no-attach::
132Disable the creation of an attachment, overriding the
133configuration setting.
134
Junio C Hamanoc51fede2007-03-12 07:29:20135--inline[=<boundary>]::
136Create multipart/mixed attachment, the first part of
137which is the commit message and the patch itself in the
Junio C Hamano3b70d3c2009-11-21 17:37:37138second part, with `Content-Disposition: inline`.
Junio C Hamano2496ae42006-03-11 08:04:33139
Junio C Hamanoea6a7642009-03-11 23:56:19140--thread[=<style>]::
Junio C Hamano1bbd0f42009-07-23 06:20:29141--no-thread::
Junio C Hamano3b70d3c2009-11-21 17:37:37142Controls addition of `In-Reply-To` and `References` headers to
Junio C Hamano1bbd0f42009-07-23 06:20:29143make the second and subsequent mails appear as replies to the
Junio C Hamano3b70d3c2009-11-21 17:37:37144first. Also controls generation of the `Message-Id` header to
Junio C Hamano1bbd0f42009-07-23 06:20:29145reference.
Junio C Hamanoea6a7642009-03-11 23:56:19146+
147The optional <style> argument can be either `shallow` or `deep`.
Junio C Hamanof4581102009-04-25 08:29:59148'shallow' threading makes every mail a reply to the head of the
Junio C Hamanoea6a7642009-03-11 23:56:19149series, where the head is chosen from the cover letter, the
Junio C Hamanob76a6862012-05-02 22:02:46150`--in-reply-to`, and the first patch mail, in this order. 'deep'
Junio C Hamano1bbd0f42009-07-23 06:20:29151threading makes every mail a reply to the previous one.
152+
Junio C Hamano042f2142016-06-27 18:05:05153The default is `--no-thread`, unless the `format.thread` configuration
Junio C Hamano3b70d3c2009-11-21 17:37:37154is set. If `--thread` is specified without a style, it defaults to the
Junio C Hamano042f2142016-06-27 18:05:05155style specified by `format.thread` if any, or else `shallow`.
Junio C Hamano1bbd0f42009-07-23 06:20:29156+
157Beware that the default for 'git send-email' is to thread emails
Junio C Hamano3b70d3c2009-11-21 17:37:37158itself. If you want `git format-patch` to take care of threading, you
159will want to ensure that threading is disabled for `git send-email`.
Junio C Hamanof9ca97d2006-07-25 22:23:09160
161--in-reply-to=Message-Id::
Junio C Hamano3b70d3c2009-11-21 17:37:37162Make the first mail (or all the mails with `--no-thread`) appear as a
Junio C Hamanof9ca97d2006-07-25 22:23:09163reply to the given Message-Id, which avoids breaking threads to
164provide a new patch series.
Junio C Hamano2496ae42006-03-11 08:04:33165
Junio C Hamano7c73c662007-01-19 00:37:50166--ignore-if-in-upstream::
167Do not include a patch that matches a commit in
168<until>..<since>. This will examine all patches reachable
169from <since> but not from <until> and compare them with the
170patches being generated, and any patch that matches is
171ignored.
172
Junio C Hamano6f1cca82007-04-12 05:02:47173--subject-prefix=<Subject-Prefix>::
174Instead of the standard '[PATCH]' prefix in the subject
175line, instead use '[<Subject-Prefix>]'. This
176allows for useful naming of a patch series, and can be
Junio C Hamano3b70d3c2009-11-21 17:37:37177combined with the `--numbered` option.
Junio C Hamano6f1cca82007-04-12 05:02:47178
Junio C Hamanoad70bf02016-09-26 23:44:27179--rfc::
180Alias for `--subject-prefix="RFC PATCH"`. RFC means "Request For
181Comments"; use this when sending an experimental patch for
182discussion rather than application.
183
Junio C Hamano7dac6902013-01-12 08:25:31184-v <n>::
185--reroll-count=<n>::
186Mark the series as the <n>-th iteration of the topic. The
Junio C Hamanodf5384b2015-06-24 21:12:12187output filenames have `v<n>` prepended to them, and the
Junio C Hamano7dac6902013-01-12 08:25:31188subject prefix ("PATCH" by default, but configurable via the
189`--subject-prefix` option) has ` v<n>` appended to it. E.g.
190`--reroll-count=4` may produce `v4-0001-add-makefile.patch`
191file that has "Subject: [PATCH v4 1/20] Add makefile" in it.
192
Junio C Hamanoea90ab32010-03-15 20:32:55193--to=<email>::
194Add a `To:` header to the email headers. This is in addition
195to any configured headers, and may be used multiple times.
Junio C Hamano7bd050f2011-09-22 06:32:22196The negated form `--no-to` discards all `To:` headers added so
197far (from config or command line).
Junio C Hamanoea90ab32010-03-15 20:32:55198
Junio C Hamano24bc09a2008-02-28 00:27:44199--cc=<email>::
Junio C Hamano3b70d3c2009-11-21 17:37:37200Add a `Cc:` header to the email headers. This is in addition
Junio C Hamano24bc09a2008-02-28 00:27:44201to any configured headers, and may be used multiple times.
Junio C Hamano7bd050f2011-09-22 06:32:22202The negated form `--no-cc` discards all `Cc:` headers added so
203far (from config or command line).
Junio C Hamano24bc09a2008-02-28 00:27:44204
Junio C Hamanoededf2b2013-07-15 21:11:16205--from::
206--from=<ident>::
207Use `ident` in the `From:` header of each commit email. If the
208author ident of the commit is not textually identical to the
209provided `ident`, place a `From:` header in the body of the
210message with the original author. If no `ident` is given, use
211the committer ident.
212+
213Note that this option is only useful if you are actually sending the
214emails and want to identify yourself as the sender, but retain the
215original author (and `git am` will correctly pick up the in-body
216header). Note also that `git send-email` already handles this
217transformation for you, and this option should not be used if you are
218feeding the result to `git send-email`.
219
Junio C Hamano9572e922009-04-02 06:52:03220--add-header=<header>::
221Add an arbitrary header to the email headers. This is in addition
222to any configured headers, and may be used multiple times.
Junio C Hamano7bd050f2011-09-22 06:32:22223For example, `--add-header="Organization: git-foo"`.
224The negated form `--no-add-header` discards *all* (`To:`,
225`Cc:`, and custom) headers added so far from config or command
226line.
Junio C Hamano9572e922009-04-02 06:52:03227
Junio C Hamanoea3b7522013-04-18 19:37:53228--[no-]cover-letter::
Junio C Hamano92a4abd2008-08-15 05:34:44229In addition to the patches, generate a cover letter file
Junio C Hamano7db630e2015-09-17 20:26:22230containing the branch description, shortlog and the overall diffstat. You can
Junio C Hamano92a4abd2008-08-15 05:34:44231fill in a description in the file before sending it out.
Junio C Hamano24bc09a2008-02-28 00:27:44232
Junio C Hamano980e61e2018-09-17 22:45:52233--interdiff=<previous>::
234As a reviewer aid, insert an interdiff into the cover letter,
235or as commentary of the lone patch of a 1-patch series, showing
236the differences between the previous version of the patch series and
237the series currently being formatted. `previous` is a single revision
238naming the tip of the previous series which shares a common base with
239the series being formatted (for example `git format-patch
240--cover-letter --interdiff=feature/v1 -3 feature/v2`).
241
242--range-diff=<previous>::
243As a reviewer aid, insert a range-diff (see linkgit:git-range-diff[1])
244into the cover letter, or as commentary of the lone patch of a
2451-patch series, showing the differences between the previous
246version of the patch series and the series currently being formatted.
247`previous` can be a single revision naming the tip of the previous
248series if it shares a common base with the series being formatted (for
249example `git format-patch --cover-letter --range-diff=feature/v1 -3
250feature/v2`), or a revision range if the two versions of the series are
251disjoint (for example `git format-patch --cover-letter
252--range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
Junio C Hamanof2b280b2018-12-01 14:45:01253+
254Note that diff options passed to the command affect how the primary
255product of `format-patch` is generated, and they are not passed to
256the underlying `range-diff` machinery used to generate the cover-letter
257material (this may change in the future).
Junio C Hamano980e61e2018-09-17 22:45:52258
259--creation-factor=<percent>::
260Used with `--range-diff`, tweak the heuristic which matches up commits
261between the previous and current series of patches by adjusting the
262creation/deletion cost fudge factor. See linkgit:git-range-diff[1])
263for details.
264
Junio C Hamano4eb2b9c2012-11-15 21:12:29265--notes[=<ref>]::
266Append the notes (see linkgit:git-notes[1]) for the commit
267after the three-dash line.
268+
269The expected use case of this is to write supporting explanation for
270the commit that does not belong to the commit log message proper,
271and include it with the patch submission. While one can simply write
272these explanations after `format-patch` has run but before sending,
Junio C Hamano076ffcc2013-02-06 05:13:21273keeping them as Git notes allows them to be maintained between versions
Junio C Hamano4eb2b9c2012-11-15 21:12:29274of the patch series (but see the discussion of the `notes.rewrite`
275configuration options in linkgit:git-notes[1] to use this workflow).
276
Junio C Hamanocb06ef92017-03-21 22:40:14277--[no-]signature=<signature>::
Junio C Hamano89a57342010-06-22 23:22:55278Add a signature to each message produced. Per RFC 3676 the signature
279is separated from the body by a line with '-- ' on it. If the
Junio C Hamano076ffcc2013-02-06 05:13:21280signature option is omitted the signature defaults to the Git version
Junio C Hamano89a57342010-06-22 23:22:55281number.
282
Junio C Hamanoc8c398a2014-06-16 21:14:05283--signature-file=<file>::
284Works just like --signature except the signature is read from a file.
285
Junio C Hamano4f9a6052007-01-17 20:25:16286--suffix=.<sfx>::
Junio C Hamano7c73c662007-01-19 00:37:50287Instead of using `.patch` as the suffix for generated
Junio C Hamanoa6387422007-08-25 03:54:27288filenames, use specified suffix. A common alternative is
Junio C Hamanof4581102009-04-25 08:29:59289`--suffix=.txt`. Leaving this empty will remove the `.patch`
290suffix.
Junio C Hamano4f9a6052007-01-17 20:25:16291+
Junio C Hamanof4581102009-04-25 08:29:59292Note that the leading character does not have to be a dot; for example,
293you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
Junio C Hamano4f9a6052007-01-17 20:25:16294
Junio C Hamano535ed7a2013-09-04 20:35:57295-q::
Junio C Hamano209ebe82011-04-27 21:09:59296--quiet::
297Do not print the names of the generated files to standard output.
298
Junio C Hamano869bb802008-05-12 00:29:47299--no-binary::
Junio C Hamanof4581102009-04-25 08:29:59300Do not output contents of changes in binary files, instead
301display a notice that those files changed. Patches generated
302using this option cannot be applied properly, but they are
303still useful for code review.
Junio C Hamano869bb802008-05-12 00:29:47304
Junio C Hamano409a33a2015-12-22 23:45:23305--zero-commit::
306 Output an all-zero hash in each patch's From header instead
307 of the hash of the commit.
308
Junio C Hamanof2a3a752016-05-23 22:54:39309--base=<commit>::
310Record the base tree information to identify the state the
311patch series applies to. See the BASE TREE INFORMATION section
312below for details.
313
Junio C Hamano9572e922009-04-02 06:52:03314--root::
315Treat the revision argument as a <revision range>, even if it
316is just a single commit (that would normally be treated as a
317<since>). Note that root commits included in the specified
318range are always formatted as creation patches, independently
319of this flag.
320
Junio C Hamanoa4ff7292017-08-23 21:56:43321--progress::
322Show progress reports on stderr as patches are generated.
323
Junio C Hamano2496ae42006-03-11 08:04:33324CONFIGURATION
325-------------
Junio C Hamanof4581102009-04-25 08:29:59326You can specify extra mail header lines to be added to each message,
327defaults for the subject prefix and file suffix, number patches when
Junio C Hamanoea90ab32010-03-15 20:32:55328outputting more than one patch, add "To" or "Cc:" headers, configure
329attachments, and sign off patches with configuration variables.
Junio C Hamano2496ae42006-03-11 08:04:33330
Junio C Hamano7c73c662007-01-19 00:37:50331------------
Junio C Hamano2496ae42006-03-11 08:04:33332[format]
Junio C Hamanoba4b9282008-07-06 05:20:31333headers = "Organization: git-foo\n"
Junio C Hamano322c6242015-03-23 21:32:46334subjectPrefix = CHANGE
Junio C Hamanoba4b9282008-07-06 05:20:31335suffix = .txt
336numbered = auto
Junio C Hamanoea90ab32010-03-15 20:32:55337to = <email>
Junio C Hamano2fbcd212008-05-14 22:26:07338cc = <email>
Junio C Hamano0a235222009-03-06 08:21:09339attach [ = mime-boundary-string ]
Junio C Hamano322c6242015-03-23 21:32:46340signOff = true
Junio C Hamanoea3b7522013-04-18 19:37:53341coverletter = auto
Junio C Hamano7c73c662007-01-19 00:37:50342------------
Junio C Hamano4f9a6052007-01-17 20:25:16343
Junio C Hamano1a4e8412005-12-27 08:17:23344
Junio C Hamanob77f8192011-05-05 01:30:38345DISCUSSION
346----------
347
348The patch produced by 'git format-patch' is in UNIX mailbox format,
349with a fixed "magic" time stamp to indicate that the file is output
350from format-patch rather than a real mailbox, like so:
351
352------------
353From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001
354From: Tony Luck <tony.luck@intel.com>
355Date: Tue, 13 Jul 2010 11:42:54 -0700
356Subject: [PATCH] =?UTF-8?q?[IA64]=20Put=20ia64=20config=20files=20on=20the=20?=
357 =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20diet?=
358MIME-Version: 1.0
359Content-Type: text/plain; charset=UTF-8
360Content-Transfer-Encoding: 8bit
361
362arch/arm config files were slimmed down using a python script
363(See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment)
364
365Do the same for ia64 so we can have sleek & trim looking
366...
367------------
368
369Typically it will be placed in a MUA's drafts folder, edited to add
370timely commentary that should not go in the changelog after the three
371dashes, and then sent as a message whose body, in our example, starts
372with "arch/arm config files were...". On the receiving end, readers
373can save interesting patches in a UNIX mailbox and apply them with
374linkgit:git-am[1].
375
376When a patch is part of an ongoing discussion, the patch generated by
377'git format-patch' can be tweaked to take advantage of the 'git am
378--scissors' feature. After your response to the discussion comes a
379line that consists solely of "`-- >8 --`" (scissors and perforation),
380followed by the patch with unnecessary header fields removed:
381
382------------
383...
384> So we should do such-and-such.
385
386Makes sense to me. How about this patch?
387
388-- >8 --
389Subject: [IA64] Put ia64 config files on the Uwe Kleine-König diet
390
391arch/arm config files were slimmed down using a python script
392...
393------------
394
395When sending a patch this way, most often you are sending your own
396patch, so in addition to the "`From $SHA1 $magic_timestamp`" marker you
397should omit `From:` and `Date:` lines from the patch file. The patch
398title is likely to be different from the subject of the discussion the
399patch is in response to, so it is likely that you would want to keep
400the Subject: line, like the example above.
401
402Checking for patch corruption
403~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404Many mailers if not set up properly will corrupt whitespace. Here are
405two common types of corruption:
406
407* Empty context lines that do not have _any_ whitespace.
408
409* Non-empty context lines that have one extra whitespace at the
410 beginning.
411
412One way to test if your MUA is set up correctly is:
413
414* Send the patch to yourself, exactly the way you would, except
415 with To: and Cc: lines that do not contain the list and
416 maintainer address.
417
418* Save that patch to a file in UNIX mailbox format. Call it a.patch,
419 say.
420
421* Apply it:
422
423 $ git fetch <project> master:test-apply
424 $ git checkout test-apply
425 $ git reset --hard
426 $ git am a.patch
427
428If it does not apply correctly, there can be various reasons.
429
430* The patch itself does not apply cleanly. That is _bad_ but
431 does not have much to do with your MUA. You might want to rebase
432 the patch with linkgit:git-rebase[1] before regenerating it in
433 this case.
434
435* The MUA corrupted your patch; "am" would complain that
436 the patch does not apply. Look in the .git/rebase-apply/ subdirectory and
437 see what 'patch' file contains and check for the common
438 corruption patterns mentioned above.
439
440* While at it, check the 'info' and 'final-commit' files as well.
441 If what is in 'final-commit' is not exactly what you would want to
442 see in the commit log message, it is very likely that the
443 receiver would end up hand editing the log message when applying
444 your patch. Things like "Hi, this is my first patch.\n" in the
445 patch e-mail should come after the three-dash line that signals
446 the end of the commit message.
447
448MUA-SPECIFIC HINTS
449------------------
450Here are some hints on how to successfully submit patches inline using
451various mailers.
452
453GMail
454~~~~~
455GMail does not have any way to turn off line wrapping in the web
456interface, so it will mangle any emails that you send. You can however
457use "git send-email" and send your patches through the GMail SMTP server, or
458use any IMAP email client to connect to the google IMAP server and forward
459the emails through that.
460
461For hints on using 'git send-email' to send your patches through the
462GMail SMTP server, see the EXAMPLE section of linkgit:git-send-email[1].
463
464For hints on submission using the IMAP interface, see the EXAMPLE
465section of linkgit:git-imap-send[1].
466
467Thunderbird
468~~~~~~~~~~~
469By default, Thunderbird will both wrap emails as well as flag
470them as being 'format=flowed', both of which will make the
Junio C Hamano076ffcc2013-02-06 05:13:21471resulting email unusable by Git.
Junio C Hamanob77f8192011-05-05 01:30:38472
473There are three different approaches: use an add-on to turn off line wraps,
474configure Thunderbird to not mangle patches, or use
475an external editor to keep Thunderbird from mangling the patches.
476
477Approach #1 (add-on)
478^^^^^^^^^^^^^^^^^^^^
479
480Install the Toggle Word Wrap add-on that is available from
481https://addons.mozilla.org/thunderbird/addon/toggle-word-wrap/
482It adds a menu entry "Enable Word Wrap" in the composer's "Options" menu
483that you can tick off. Now you can compose the message as you otherwise do
484(cut + paste, 'git format-patch' | 'git imap-send', etc), but you have to
485insert line breaks manually in any text that you type.
486
487Approach #2 (configuration)
488^^^^^^^^^^^^^^^^^^^^^^^^^^^
489Three steps:
490
4911. Configure your mail server composition as plain text:
492 Edit...Account Settings...Composition & Addressing,
493 uncheck "Compose Messages in HTML".
494
4952. Configure your general composition window to not wrap.
496+
497In Thunderbird 2:
498Edit..Preferences..Composition, wrap plain text messages at 0
499+
500In Thunderbird 3:
501Edit..Preferences..Advanced..Config Editor. Search for
502"mail.wrap_long_lines".
Junio C Hamano369e3402013-10-15 18:40:25503Toggle it to make sure it is set to `false`. Also, search for
504"mailnews.wraplength" and set the value to 0.
Junio C Hamanob77f8192011-05-05 01:30:38505
5063. Disable the use of format=flowed:
507Edit..Preferences..Advanced..Config Editor. Search for
508"mailnews.send_plaintext_flowed".
509Toggle it to make sure it is set to `false`.
510
511After that is done, you should be able to compose email as you
512otherwise would (cut + paste, 'git format-patch' | 'git imap-send', etc),
513and the patches will not be mangled.
514
515Approach #3 (external editor)
516^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
517
518The following Thunderbird extensions are needed:
519AboutConfig from http://aboutconfig.mozdev.org/ and
520External Editor from http://globs.org/articles.php?lng=en&pg=8
521
5221. Prepare the patch as a text file using your method of choice.
523
5242. Before opening a compose window, use Edit->Account Settings to
525 uncheck the "Compose messages in HTML format" setting in the
526 "Composition & Addressing" panel of the account to be used to
527 send the patch.
528
5293. In the main Thunderbird window, 'before' you open the compose
530 window for the patch, use Tools->about:config to set the
531 following to the indicated values:
532+
533----------
534mailnews.send_plaintext_flowed => false
535mailnews.wraplength => 0
536----------
537
5384. Open a compose window and click the external editor icon.
539
5405. In the external editor window, read in the patch file and exit
541 the editor normally.
542
543Side note: it may be possible to do step 2 with
544about:config and the following settings but no one's tried yet.
545
546----------
547mail.html_compose => false
548mail.identity.default.compose_html => false
549mail.identity.id?.compose_html => false
550----------
551
552There is a script in contrib/thunderbird-patch-inline which can help
553you include patches with Thunderbird in an easy way. To use it, do the
554steps above and then use the script as the external editor.
555
556KMail
557~~~~~
558This should help you to submit patches inline using KMail.
559
5601. Prepare the patch as a text file.
561
5622. Click on New Mail.
563
5643. Go under "Options" in the Composer window and be sure that
565 "Word wrap" is not set.
566
5674. Use Message -> Insert file... and insert the patch.
568
5695. Back in the compose window: add whatever other text you wish to the
570 message, complete the addressing and subject fields, and press send.
571
Junio C Hamanof2a3a752016-05-23 22:54:39572BASE TREE INFORMATION
573---------------------
574
575The base tree information block is used for maintainers or third party
576testers to know the exact state the patch series applies to. It consists
577of the 'base commit', which is a well-known commit that is part of the
578stable part of the project history everybody else works off of, and zero
579or more 'prerequisite patches', which are well-known patches in flight
580that is not yet part of the 'base commit' that need to be applied on top
581of 'base commit' in topological order before the patches can be applied.
582
583The 'base commit' is shown as "base-commit: " followed by the 40-hex of
584the commit object name. A 'prerequisite patch' is shown as
585"prerequisite-patch-id: " followed by the 40-hex 'patch id', which can
586be obtained by passing the patch through the `git patch-id --stable`
587command.
588
589Imagine that on top of the public commit P, you applied well-known
590patches X, Y and Z from somebody else, and then built your three-patch
591series A, B, C, the history would be like:
592
593................................................
594---P---X---Y---Z---A---B---C
595................................................
596
597With `git format-patch --base=P -3 C` (or variants thereof, e.g. with
Junio C Hamanoe25cc812017-04-24 06:17:43598`--cover-letter` or using `Z..C` instead of `-3 C` to specify the
Junio C Hamanof2a3a752016-05-23 22:54:39599range), the base tree information block is shown at the end of the
600first message the command outputs (either the first patch, or the
601cover letter), like this:
602
603------------
604base-commit: P
605prerequisite-patch-id: X
606prerequisite-patch-id: Y
607prerequisite-patch-id: Z
608------------
609
610For non-linear topology, such as
611
612................................................
613---P---X---A---M---C
614 \ /
615 Y---Z---B
616................................................
617
618You can also use `git format-patch --base=P -3 C` to generate patches
619for A, B and C, and the identifiers for P, X, Y, Z are appended at the
620end of the first message.
621
622If set `--base=auto` in cmdline, it will track base commit automatically,
623the base commit will be the merge base of tip commit of the remote-tracking
624branch and revision-range specified in cmdline.
625For a local branch, you need to track a remote branch by `git branch
626--set-upstream-to` before using this option.
Junio C Hamanob77f8192011-05-05 01:30:38627
Junio C Hamano1a4e8412005-12-27 08:17:23628EXAMPLES
629--------
630
Junio C Hamano6d76d612008-05-09 05:46:08631* Extract commits between revisions R1 and R2, and apply them on top of
Junio C Hamano1aa40d22010-01-21 17:46:43632the current branch using 'git am' to cherry-pick them:
Junio C Hamano6d76d612008-05-09 05:46:08633+
634------------
Junio C Hamanoba4b9282008-07-06 05:20:31635$ git format-patch -k --stdout R1..R2 | git am -3 -k
Junio C Hamano6d76d612008-05-09 05:46:08636------------
Junio C Hamano1a4e8412005-12-27 08:17:23637
Junio C Hamano6d76d612008-05-09 05:46:08638* Extract all commits which are in the current branch but not in the
639origin branch:
640+
641------------
642$ git format-patch origin
643------------
644+
645For each commit a separate file is created in the current directory.
Junio C Hamano1a4e8412005-12-27 08:17:23646
Junio C Hamano6d76d612008-05-09 05:46:08647* Extract all commits that lead to 'origin' since the inception of the
648project:
649+
650------------
Junio C Hamanoba4b9282008-07-06 05:20:31651$ git format-patch --root origin
Junio C Hamano6d76d612008-05-09 05:46:08652------------
Junio C Hamano7d9e9bd2007-08-29 07:31:47653
Junio C Hamano6d76d612008-05-09 05:46:08654* The same as the previous one:
655+
656------------
657$ git format-patch -M -B origin
658------------
659+
660Additionally, it detects and handles renames and complete rewrites
661intelligently to produce a renaming patch. A renaming patch reduces
Junio C Hamanof4581102009-04-25 08:29:59662the amount of text output, and generally makes it easier to review.
Junio C Hamano076ffcc2013-02-06 05:13:21663Note that non-Git "patch" programs won't understand renaming patches, so
664use it only when you know the recipient uses Git to apply your patch.
Junio C Hamano1a4e8412005-12-27 08:17:23665
Junio C Hamano6d76d612008-05-09 05:46:08666* Extract three topmost commits from the current branch and format them
667as e-mailable patches:
668+
669------------
670$ git format-patch -3
671------------
Junio C Hamano1a4e8412005-12-27 08:17:23672
Junio C Hamano9049d912008-05-29 02:09:50673SEE ALSO
Junio C Hamano1a4e8412005-12-27 08:17:23674--------
Junio C Hamano35738e82008-01-07 07:55:46675linkgit:git-am[1], linkgit:git-send-email[1]
Junio C Hamano1a4e8412005-12-27 08:17:23676
Junio C Hamano1a4e8412005-12-27 08:17:23677GIT
678---
Junio C Hamanof7c042d2008-06-06 22:50:53679Part of the linkgit:git[1] suite