interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-format-patch.adoc

837 lines · 31317 bytes Raw Blame History
1git-format-patch(1)
2===================
3
4NAME
5----
6git-format-patch - Prepare patches for e-mail submission
7
8
9SYNOPSIS
10--------
11[synopsis]
12git format-patch [-k] [(-o|--output-directory) <dir> | --stdout]
13 [--no-thread | --thread[=<style>]]
14 [(--attach|--inline)[=<boundary>] | --no-attach]
15 [-s | --signoff]
16 [--signature=<signature> | --no-signature]
17 [--signature-file=<file>]
18 [-n | --numbered | -N | --no-numbered]
19 [--start-number <n>] [--numbered-files]
20 [--in-reply-to=<message-id>] [--suffix=.<sfx>]
21 [--ignore-if-in-upstream] [--always]
22 [--cover-from-description=<mode>]
23 [--rfc[=<rfc>]] [--subject-prefix=<subject-prefix>]
24 [(--reroll-count|-v) <n>]
25 [--to=<email>] [--cc=<email>]
26 [--[no-]cover-letter] [--quiet]
27 [--commit-list-format=<format-spec>]
28 [--[no-]encode-email-headers]
29 [--no-notes | --notes[=<ref>]]
30 [--interdiff=<previous>]
31 [--range-diff=<previous> [--creation-factor=<percent>]]
32 [--filename-max-length=<n>]
33 [--progress]
34 [<common-diff-options>]
35 [ <since> | <revision-range> ]
36
37DESCRIPTION
38-----------
39
40Prepare each non-merge commit with its "patch" in
41one "message" per commit, formatted to resemble a UNIX mailbox.
42The output of this command is convenient for e-mail submission or
43for use with `git am`.
44
45A "message" generated by the command consists of three parts:
46
47* A brief metadata header that begins with `From <commit>`
48 with a fixed `Mon Sep 17 00:00:00 2001` datestamp to help programs
49 like `file`(1) to recognize that the file is an output from this
50 command, fields that record the author identity, the author date,
51 and the title of the change (taken from the first paragraph of the
52 commit log message).
53
54* The second and subsequent paragraphs of the commit log message.
55
56* The "patch", which is the `diff -p --stat` output (see
57 linkgit:git-diff[1]) between the commit and its parent.
58
59The log message and the patch are separated by a line with a
60three-dash line.
61
62There are two ways to specify which commits to operate on.
63
641. A single commit, _<since>_, specifies that the commits leading
65 to the tip of the current branch that are not in the history
66 that leads to the _<since>_ to be output.
67
682. Generic _<revision-range>_ expression (see 'SPECIFYING
69 REVISIONS' section in linkgit:gitrevisions[7]) means the
70 commits in the specified range.
71
72The first rule takes precedence in the case of a single _<commit>_. To
73apply the second rule, i.e., format everything since the beginning of
74history up until _<commit>_, use the `--root` option: `git format-patch
75--root <commit>`. If you want to format only _<commit>_ itself, you
76can do this with `git format-patch -1 <commit>`.
77
78By default, each output file is numbered sequentially from 1, and uses the
79first line of the commit message (massaged for pathname safety) as
80the filename. With the `--numbered-files` option, the output file names
81will only be numbers, without the first line of the commit appended.
82The names of the output files are printed to standard
83output, unless the `--stdout` option is specified.
84
85If `-o` is specified, output files are created in _<dir>_. Otherwise
86they are created in the current working directory. The default path
87can be set with the `format.outputDirectory` configuration option.
88The `-o` option takes precedence over `format.outputDirectory`.
89To store patches in the current working directory even when
90`format.outputDirectory` points elsewhere, use `-o .`. All directory
91components will be created.
92
93By default, the subject of a single patch is "[PATCH] " followed by
94the concatenation of lines from the commit message up to the first blank
95line (see the DISCUSSION section of linkgit:git-commit[1]).
96
97When multiple patches are output, the subject prefix will instead be
98"[PATCH n/m] ". To force 1/1 to be added for a single patch, use `-n`.
99To omit patch numbers from the subject, use `-N`.
100
101If given `--thread`, `git-format-patch` will generate `In-Reply-To` and
102`References` headers to make the second and subsequent patch mails appear
103as replies to the first mail; this also generates a `Message-ID` header to
104reference.
105
106OPTIONS
107-------
108:git-format-patch: 1
109include::diff-options.adoc[]
110
111`-<n>`::
112 Prepare patches from the topmost _<n>_ commits.
113
114`-o <dir>`::
115`--output-directory=<dir>`::
116 Use _<dir>_ to store the resulting files, instead of the
117 current working directory.
118
119`-n`::
120`--numbered`::
121 Name output in '[PATCH n/m]' format, even with a single patch.
122
123`-N`::
124`--no-numbered`::
125 Name output in '[PATCH]' format.
126
127`--start-number <n>`::
128 Start numbering the patches at _<n>_ instead of 1.
129
130`--numbered-files`::
131 Output file names will be a simple number sequence
132 without the default first line of the commit appended.
133
134`-k`::
135`--keep-subject`::
136 Do not strip/add '[PATCH]' from the first line of the
137 commit log message.
138
139`-s`::
140`--signoff`::
141 Add a `Signed-off-by` trailer to the commit message, using
142 the committer identity of yourself.
143 See the signoff option in linkgit:git-commit[1] for more information.
144
145`--stdout`::
146 Print all commits to the standard output in mbox format,
147 instead of creating a file for each one.
148
149`--attach[=<boundary>]`::
150 Create multipart/mixed attachment, the first part of
151 which is the commit message and the patch itself in the
152 second part, with `Content-Disposition: attachment`.
153
154`--no-attach`::
155 Disable the creation of an attachment, overriding the
156 configuration setting.
157
158`--inline[=<boundary>]`::
159 Create multipart/mixed attachment, the first part of
160 which is the commit message and the patch itself in the
161 second part, with `Content-Disposition: inline`.
162
163`--thread[=<style>]`::
164`--no-thread`::
165 Control addition of `In-Reply-To` and `References` headers to
166 make the second and subsequent mails appear as replies to the
167 first. Also controls generation of the `Message-ID` header to
168 reference.
169+
170The optional _<style>_ argument can be either `shallow` or `deep`.
171`shallow` threading makes every mail a reply to the head of the
172series, where the head is chosen from the cover letter, the
173`--in-reply-to`, and the first patch mail, in this order. `deep`
174threading makes every mail a reply to the previous one.
175+
176The default is `--no-thread`, unless the `format.thread` configuration
177is set. `--thread` without an argument is equivalent to `--thread=shallow`.
178+
179Beware that the default for `git send-email` is to thread emails
180itself. If you want `git format-patch` to take care of threading, you
181will want to ensure that threading is disabled for `git send-email`.
182
183`--in-reply-to=<message-id>`::
184 Make the first mail (or all the mails with `--no-thread`) appear as a
185 reply to the given _<message-id>_, which avoids breaking threads to
186 provide a new patch series.
187
188`--ignore-if-in-upstream`::
189 Do not include a patch that matches a commit in
190 _<until>_.._<since>_. This will examine all patches reachable
191 from _<since>_ but not from _<until>_ and compare them with the
192 patches being generated, and any patch that matches is
193 ignored.
194
195`--always`::
196 Include patches for commits that do not introduce any change,
197 which are omitted by default.
198
199`--cover-from-description=<mode>`::
200 Control which parts of the cover letter will be automatically
201 populated using the branch's description.
202+
203_<mode>_ can have the following values:
204
205`message`;;
206`default`;; the cover letter subject will be
207populated with placeholder text. The body of the cover letter will be
208populated with the branch's description. This is the default mode when
209no configuration nor command line option is specified.
210`subject`;; the first paragraph of the branch description will
211populate the cover letter subject. The remainder of the description will
212populate the body of the cover letter.
213`auto`;; if the first paragraph of the branch description
214is greater than 100 bytes, then the mode will be `message`, otherwise
215`subject` will be used.
216`none`;; both the cover letter subject and body will be
217populated with placeholder text.
218
219`--description-file=<file>`::
220 Use the contents of _<file>_ instead of the branch's description
221 for generating the cover letter.
222
223`--subject-prefix=<subject-prefix>`::
224 Use '[<subject-prefix>]' instead of the standard '[PATCH]'
225 prefix in the subject line. This can be used to name a patch
226 series, and can be combined with the `--numbered` option.
227+
228The configuration variable `format.subjectPrefix` may also be used
229to configure a subject prefix to apply to a given repository for
230all patches. This is often useful on mailing lists which receive
231patches for several repositories and can be used to disambiguate
232the patches (with a value of e.g. "PATCH my-project").
233
234`--filename-max-length=<n>`::
235 Instead of the standard 64 bytes, chomp the generated output
236 filenames at around _<n>_ bytes (too short a value will be
237 silently raised to a reasonable length). Defaults to the
238 value of the `format.filenameMaxLength` configuration
239 variable, or 64 if unconfigured.
240
241`--rfc[=<rfc>]`::
242 Prepends the string _<rfc>_ (defaults to "RFC") to
243 the subject prefix. As the subject prefix defaults to
244 "PATCH", you'll get "RFC PATCH" by default.
245+
246RFC means "Request For Comments"; use this when sending
247an experimental patch for discussion rather than application.
248"--rfc=WIP" may also be a useful way to indicate that a patch
249is not complete yet ("WIP" stands for "Work In Progress").
250+
251If the convention of the receiving community for a particular extra
252string is to have it _after_ the subject prefix, the string _<rfc>_
253can be prefixed with a dash ("`-`") to signal that the rest of
254the _<rfc>_ string should be appended to the subject prefix instead,
255e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
256
257`-v <n>`::
258`--reroll-count=<n>`::
259 Mark the series as the _<n>_-th iteration of the topic. The
260 output filenames have `v<n>` prepended to them, and the
261 subject prefix ("PATCH" by default, but configurable via the
262 `--subject-prefix` option) has `v<n>` appended to it. E.g.
263 `--reroll-count=4` may produce `v4-0001-add-makefile.patch`
264 file that has "Subject: [PATCH v4 1/20] Add makefile" in it.
265 _<n>_ does not have to be an integer (e.g. `--reroll-count=4.4`,
266 or `--reroll-count=4rev2` are allowed), but the downside of
267 using such a reroll-count is that the range-diff/interdiff
268 with the previous version does not state exactly which
269 version the new iteration is compared against.
270
271`--to=<email>`::
272 Add a `To:` header to the email headers. This is in addition
273 to any configured headers, and may be used multiple times.
274 The negated form `--no-to` discards all `To:` headers added so
275 far (from config or command line).
276
277`--cc=<email>`::
278 Add a `Cc:` header to the email headers. This is in addition
279 to any configured headers, and may be used multiple times.
280 The negated form `--no-cc` discards all `Cc:` headers added so
281 far (from config or command line).
282
283`--from`::
284`--from=<ident>`::
285 Use _<ident>_ in the `From:` header of each email. In case of a
286 commit email, if the author ident of the commit is not textually
287 identical to the provided _<ident>_, place a `From:` header in the
288 body of the message with the original author. If no _<ident>_ is
289 given, or if the option is not passed at all, use the ident of
290 the current committer.
291+
292Note that this option is only useful if you are actually sending the
293emails and want to identify yourself as the sender, but retain the
294original author (and `git am` will correctly pick up the in-body
295header). Note also that `git send-email` already handles this
296transformation for you, and this option should not be used if you are
297feeding the result to `git send-email`.
298
299`--force-in-body-from`::
300`--no-force-in-body-from`::
301 With the e-mail sender specified via the `--from` option, by
302 default, an in-body "From:" to identify the real author of
303 the commit is added at the top of the commit log message if
304 the sender is different from the author. With this option,
305 the in-body "From:" is added even when the sender and the
306 author have the same name and address, which may help if the
307 mailing list software mangles the sender's identity.
308 Defaults to the value of the `format.forceInBodyFrom`
309 configuration variable.
310
311`--add-header=<header>`::
312 Add an arbitrary header to the email headers. This is in addition
313 to any configured headers, and may be used multiple times.
314 For example, `--add-header="Organization: git-foo"`.
315 The negated form `--no-add-header` discards *all* (`To:`,
316 `Cc:`, and custom) headers added so far from config or command
317 line.
318
319`--cover-letter`::
320`--no-cover-letter`::
321 In addition to the patches, generate a cover letter file containing the
322 branch description, commit list and the overall diffstat. You can fill
323 in a description in the file before sending it out.
324
325`--commit-list-format=<format-spec>`::
326 Specify the format in which to generate the commit list of the patch
327 series. The accepted values for format-spec are `shortlog`, `modern` or
328 a format-string prefixed with `log:`. E.g. `log: %s (%an)`.
329 `modern` is the same as `log:%w(72)[%(count)/%(total)] %s`.
330 The `log:` prefix can be omitted if the format-string has a `%` in it
331 (expecting that it is part of `%<placeholder>`).
332 Defaults to the `format.commitListFormat` configuration variable, if
333 set, or `shortlog`.
334 This option given from the command-line implies the use of
335 `--cover-letter` unless `--no-cover-letter` is given.
336
337`--encode-email-headers`::
338`--no-encode-email-headers`::
339 Encode email headers that have non-ASCII characters with
340 "Q-encoding" (described in RFC 2047), instead of outputting the
341 headers verbatim. Defaults to the value of the
342 `format.encodeEmailHeaders` configuration variable.
343
344`--interdiff=<previous>`::
345 As a reviewer aid, insert an interdiff into the cover letter,
346 or as commentary of the lone patch of a 1-patch series, showing
347 the differences between the previous version of the patch series and
348 the series currently being formatted. _<previous>_ is a single revision
349 naming the tip of the previous series which shares a common base with
350 the series being formatted (for example `git format-patch
351 --cover-letter --interdiff=feature/v1 -3 feature/v2`).
352
353`--range-diff=<previous>`::
354 As a reviewer aid, insert a range-diff (see linkgit:git-range-diff[1])
355 into the cover letter, or as commentary of the lone patch of a
356 1-patch series, showing the differences between the previous
357 version of the patch series and the series currently being formatted.
358 _<previous>_ can be a single revision naming the tip of the previous
359 series if it shares a common base with the series being formatted (for
360 example `git format-patch --cover-letter --range-diff=feature/v1 -3
361 feature/v2`), or a revision range if the two versions of the series are
362 disjoint (for example `git format-patch --cover-letter
363 --range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
364+
365Note that diff options passed to the command affect how the primary
366product of `format-patch` is generated, and they are not passed to
367the underlying `range-diff` machinery used to generate the cover-letter
368material (this may change in the future).
369
370`--creation-factor=<percent>`::
371 Used with `--range-diff`, tweak the heuristic which matches up commits
372 between the previous and current series of patches by adjusting the
373 creation/deletion cost fudge factor. See linkgit:git-range-diff[1])
374 for details.
375+
376Defaults to 999 (the linkgit:git-range-diff[1] uses 60), as the use
377case is to show comparison with an older iteration of the same
378topic and the tool should find more correspondence between the two
379sets of patches.
380
381`--range-diff-notes=<ref>`::
382`--no-range-diff-notes`::
383 Used with `--range-diff`, tweak what notes to display in the
384 range diff.
385+
386The default behavior is to display the same notes in the range diff as
387on the patches; see `--notes`. Use `--range-diff-notes=<ref>` to use
388_<ref>_ for the range diff instead. This option can be given multiple
389times to show notes from multiple refs. Use `--no-range-diff-notes` to
390disable notes in the range diff.
391
392`--notes[=<ref>]`::
393`--no-notes`::
394 Append the notes (see linkgit:git-notes[1]) for the commit
395 after the three-dash line.
396+
397The expected use case of this is to write supporting explanation for
398the commit that does not belong to the commit log message proper,
399and include it with the patch submission. While one can simply write
400these explanations after `format-patch` has run but before sending,
401keeping them as Git notes allows them to be maintained between versions
402of the patch series (but see the discussion of the `notes.rewrite`
403configuration options in linkgit:git-notes[1] to use this workflow).
404+
405The default is `--no-notes`, unless the `format.notes` configuration is
406set.
407
408`--signature=<signature>`::
409`--no-signature`::
410 Add a signature to each message produced. Per RFC 3676 the signature
411 is separated from the body by a line with "-- " on it. If the
412 signature option is omitted the signature defaults to the Git version
413 number.
414
415`--signature-file=<file>`::
416 Works just like `--signature` except the signature is read from a file.
417
418`--suffix=.<sfx>`::
419 Instead of using `.patch` as the suffix for generated
420 filenames, use specified suffix. A common alternative is
421 `--suffix=.txt`. Leaving this empty will remove the `.patch`
422 suffix.
423+
424Note that the leading character does not have to be a dot; for example,
425you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
426
427`-q`::
428`--quiet`::
429 Do not print the names of the generated files to standard output.
430
431`--no-binary`::
432 Do not output contents of changes in binary files, instead
433 display a notice that those files changed. Patches generated
434 using this option cannot be applied properly, but they are
435 still useful for code review.
436
437`--zero-commit`::
438 Output an all-zero hash in each patch's From header instead
439 of the hash of the commit.
440
441`--no-base`::
442`--base[=<commit>]`::
443 Record the base tree information to identify the state the
444 patch series applies to. See the
445 <<BASE_TREE_INFORMATION,BASE TREE INFORMATION>> section
446 below for details. If _<commit>_ is `auto`, a base commit is
447 automatically chosen. The `--no-base` option overrides a
448 `format.useAutoBase` configuration.
449
450`--root`::
451 Treat the revision argument as a _<revision-range>_, even if it
452 is just a single commit (that would normally be treated as a
453 _<since>_). Note that root commits included in the specified
454 range are always formatted as creation patches, independently
455 of this flag.
456
457`--progress`::
458 Show progress reports on stderr as patches are generated.
459
460CONFIGURATION
461-------------
462You can specify extra mail header lines to be added to each message,
463defaults for the subject prefix and file suffix, number patches when
464outputting more than one patch, add "To:" or "Cc:" headers, configure
465attachments, change the patch output directory, and sign off patches
466with configuration variables.
467
468----
469[format]
470 headers = "Organization: git-foo\n"
471 subjectPrefix = CHANGE
472 suffix = .txt
473 numbered = auto
474 to = <email>
475 cc = <email>
476 attach [ = mime-boundary-string ]
477 signOff = true
478 outputDirectory = <directory>
479 coverLetter = auto
480 commitListFormat = shortlog
481 coverFromDescription = auto
482----
483
484DISCUSSION
485----------
486
487The patch produced by `git format-patch` is in UNIX mailbox format,
488with a fixed "magic" time stamp to indicate that the file is output
489from format-patch rather than a real mailbox, like so:
490
491----
492From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001
493From: Tony Luck <tony.luck@intel.com>
494Date: Tue, 13 Jul 2010 11:42:54 -0700
495Subject: [PATCH] =?UTF-8?q?[IA64]=20Put=20ia64=20config=20files=20on=20the=20?=
496 =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20diet?=
497MIME-Version: 1.0
498Content-Type: text/plain; charset=UTF-8
499Content-Transfer-Encoding: 8bit
500
501arch/arm config files were slimmed down using a python script
502(See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment)
503
504Do the same for ia64 so we can have sleek & trim looking
505...
506----
507
508Typically it will be placed in a MUA's drafts folder, edited to add
509timely commentary that should not go in the changelog after the three
510dashes, and then sent as a message whose body, in our example, starts
511with "arch/arm config files were...". On the receiving end, readers
512can save interesting patches in a UNIX mailbox and apply them with
513linkgit:git-am[1].
514
515When a patch is part of an ongoing discussion, the patch generated by
516`git format-patch` can be tweaked to take advantage of the `git am
517--scissors` feature. After your response to the discussion comes a
518line that consists solely of "`-- >8 --`" (scissors and perforation),
519followed by the patch with unnecessary header fields removed:
520
521----
522...
523> So we should do such-and-such.
524
525Makes sense to me. How about this patch?
526
527-- >8 --
528Subject: [IA64] Put ia64 config files on the Uwe Kleine-König diet
529
530arch/arm config files were slimmed down using a python script
531...
532----
533
534When sending a patch this way, most often you are sending your own
535patch, so in addition to the "`From $SHA1 $magic_timestamp`" marker you
536should omit `From:` and `Date:` lines from the patch file. The patch
537title is likely to be different from the subject of the discussion the
538patch is in response to, so it is likely that you would want to keep
539the Subject: line, like the example above.
540
541Checking for patch corruption
542~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
543Many mailers if not set up properly will corrupt whitespace. Here are
544two common types of corruption:
545
546* Empty context lines that do not have _any_ whitespace.
547
548* Non-empty context lines that have one extra whitespace at the
549 beginning.
550
551One way to test if your MUA is set up correctly is:
552
553* Send the patch to yourself, exactly the way you would, except
554 with `To:` and `Cc:` lines that do not contain the list and
555 maintainer address.
556
557* Save that patch to a file in UNIX mailbox format. Call it a.patch,
558 say.
559
560* Apply it:
561
562 $ git fetch <project> master:test-apply
563 $ git switch test-apply
564 $ git restore --source=HEAD --staged --worktree :/
565 $ git am a.patch
566
567If it does not apply correctly, there can be various reasons.
568
569* The patch itself does not apply cleanly. That is _bad_ but
570 does not have much to do with your MUA. You might want to rebase
571 the patch with linkgit:git-rebase[1] before regenerating it in
572 this case.
573
574* The MUA corrupted your patch; "am" would complain that
575 the patch does not apply. Look in the `.git/rebase-apply/` subdirectory and
576 see what `patch` file contains and check for the common
577 corruption patterns mentioned above.
578
579* While at it, check the `info` and `final-commit` files as well.
580 If what is in `final-commit` is not exactly what you would want to
581 see in the commit log message, it is very likely that the
582 receiver would end up hand editing the log message when applying
583 your patch. Things like "Hi, this is my first patch.\n" in the
584 patch e-mail should come after the three-dash line that signals
585 the end of the commit message.
586
587MUA-SPECIFIC HINTS
588------------------
589Here are some hints on how to successfully submit patches inline using
590various mailers.
591
592GMail
593~~~~~
594GMail does not have any way to turn off line wrapping in the web
595interface, so it will mangle any emails that you send. You can however
596use `git send-email` and send your patches through the GMail SMTP server, or
597use any IMAP email client to connect to the google IMAP server and forward
598the emails through that.
599
600For hints on using `git send-email` to send your patches through the
601GMail SMTP server, see the EXAMPLE section of linkgit:git-send-email[1].
602
603For hints on submission using the IMAP interface, see the EXAMPLE
604section of linkgit:git-imap-send[1].
605
606Thunderbird
607~~~~~~~~~~~
608By default, Thunderbird will both wrap emails as well as flag
609them as being `format=flowed`, both of which will make the
610resulting email unusable by Git.
611
612There are three different approaches: use an add-on to turn off line wraps,
613configure Thunderbird to not mangle patches, or use
614an external editor to keep Thunderbird from mangling the patches.
615
616Approach #1 (add-on)
617^^^^^^^^^^^^^^^^^^^^
618
619Install the Toggle Line Wrap add-on that is available from
620https://addons.thunderbird.net/thunderbird/addon/toggle-line-wrap
621It adds a button "Line Wrap" to the composer's toolbar
622that you can tick off. Now you can compose the message as you otherwise do
623(cut + paste, `git format-patch` | `git imap-send`, etc), but you have to
624insert line breaks manually in any text that you type.
625
626As a bonus feature, the add-on can detect patch text in the composer
627and warns when line wrapping has not yet been turned off.
628
629The add-on requires a few tweaks of the advanced configuration
630(`about:config`). These are listed on the download page.
631
632Approach #2 (configuration)
633^^^^^^^^^^^^^^^^^^^^^^^^^^^
634Three steps:
635
6361. Configure your mail server composition as plain text:
637 Edit...Account Settings...Composition & Addressing,
638 uncheck "Compose Messages in HTML".
639
6402. Configure your general composition window to not wrap.
641+
642In Thunderbird 2:
643Edit..Preferences..Composition, wrap plain text messages at 0
644+
645In Thunderbird 3:
646Edit..Preferences..Advanced..Config Editor. Search for
647"mail.wrap_long_lines".
648Toggle it to make sure it is set to `false`. Also, search for
649"mailnews.wraplength" and set the value to 0.
650
6513. Disable the use of format=flowed:
652 Edit..Preferences..Advanced..Config Editor. Search for
653 "mailnews.send_plaintext_flowed".
654 Toggle it to make sure it is set to `false`.
655
656After that is done, you should be able to compose email as you
657otherwise would (cut + paste, `git format-patch` | `git imap-send`, etc),
658and the patches will not be mangled.
659
660Approach #3 (external editor)
661^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
662
663The following Thunderbird extensions are needed:
664AboutConfig from https://mjg.github.io/AboutConfig/ and
665External Editor from https://globs.org/articles.php?lng=en&pg=8
666
6671. Prepare the patch as a text file using your method of choice.
668
6692. Before opening a compose window, use Edit->Account Settings to
670 uncheck the "Compose messages in HTML format" setting in the
671 "Composition & Addressing" panel of the account to be used to
672 send the patch.
673
6743. In the main Thunderbird window, _before_ you open the compose
675 window for the patch, use Tools->about:config to set the
676 following to the indicated values:
677+
678----
679 mailnews.send_plaintext_flowed => false
680 mailnews.wraplength => 0
681----
682
6834. Open a compose window and click the external editor icon.
684
6855. In the external editor window, read in the patch file and exit
686 the editor normally.
687
688Side note: it may be possible to do step 2 with
689about:config and the following settings but no one's tried yet.
690
691----
692 mail.html_compose => false
693 mail.identity.default.compose_html => false
694 mail.identity.id?.compose_html => false
695----
696
697There is a script in contrib/thunderbird-patch-inline which can help
698you include patches with Thunderbird in an easy way. To use it, do the
699steps above and then use the script as the external editor.
700
701KMail
702~~~~~
703This should help you to submit patches inline using KMail.
704
7051. Prepare the patch as a text file.
706
7072. Click on New Mail.
708
7093. Go under "Options" in the Composer window and be sure that
710 "Word wrap" is not set.
711
7124. Use Message -> Insert file... and insert the patch.
713
7145. Back in the compose window: add whatever other text you wish to the
715 message, complete the addressing and subject fields, and press send.
716
717[[BASE_TREE_INFORMATION]]
718BASE TREE INFORMATION
719---------------------
720
721The base tree information block is used for maintainers or third party
722testers to know the exact state the patch series applies to. It consists
723of the "base commit", which is a well-known commit that is part of the
724stable part of the project history everybody else works off of, and zero
725or more "prerequisite patches", which are well-known patches in flight
726that is not yet part of the "base commit" that need to be applied on top
727of "base commit" in topological order before the patches can be applied.
728
729The "base commit" is shown as "`base-commit:` " followed by the 40-hex of
730the commit object name. A "prerequisite patch" is shown as
731"`prerequisite-patch-id:` " followed by the 40-hex "patch id", which can
732be obtained by passing the patch through the `git patch-id --stable`
733command.
734
735Imagine that on top of the public commit P, you applied well-known
736patches X, Y and Z from somebody else, and then built your three-patch
737series A, B, C, the history would be like:
738
739................................................
740---P---X---Y---Z---A---B---C
741................................................
742
743With `git format-patch --base=P -3 C` (or variants thereof, e.g. with
744`--cover-letter` or using `Z..C` instead of `-3 C` to specify the
745range), the base tree information block is shown at the end of the
746first message the command outputs (either the first patch, or the
747cover letter), like this:
748
749----
750base-commit: P
751prerequisite-patch-id: X
752prerequisite-patch-id: Y
753prerequisite-patch-id: Z
754----
755
756For non-linear topology, such as
757
758................................................
759---P---X---A---M---C
760 \ /
761 Y---Z---B
762................................................
763
764You can also use `git format-patch --base=P -3 C` to generate patches
765for A, B and C, and the identifiers for P, X, Y, Z are appended at the
766end of the first message.
767
768If set `--base=auto` in cmdline, it will automatically compute
769the base commit as the merge base of tip commit of the remote-tracking
770branch and revision-range specified in cmdline.
771For a local branch, you need to make it to track a remote branch by `git branch
772--set-upstream-to` before using this option.
773
774EXAMPLES
775--------
776
777* Extract commits between revisions R1 and R2, and apply them on top of
778 the current branch using `git am` to cherry-pick them:
779+
780------------
781$ git format-patch -k --stdout R1..R2 | git am -3 -k
782------------
783
784* Extract all commits which are in the current branch but not in the
785 origin branch:
786+
787------------
788$ git format-patch origin
789------------
790+
791For each commit a separate file is created in the current directory.
792
793* Extract all commits that lead to `origin` since the inception of the
794 project:
795+
796------------
797$ git format-patch --root origin
798------------
799
800* The same as the previous one:
801+
802------------
803$ git format-patch -M -B origin
804------------
805+
806Additionally, it detects and handles renames and complete rewrites
807intelligently to produce a renaming patch. A renaming patch reduces
808the amount of text output, and generally makes it easier to review.
809Note that non-Git `patch` programs won't understand renaming patches, so
810use it only when you know the recipient uses Git to apply your patch.
811
812* Extract three topmost commits from the current branch and format them
813 as e-mailable patches:
814+
815------------
816$ git format-patch -3
817------------
818
819CAVEATS
820-------
821
822Note that `format-patch` will omit merge commits from the output, even
823if they are part of the requested range. A simple "patch" does not
824include enough information for the receiving end to reproduce the same
825merge commit.
826
827=== PATCH APPLICATION
828
829include::format-patch-caveats.adoc[]
830
831SEE ALSO
832--------
833linkgit:git-am[1], linkgit:git-send-email[1]
834
835GIT
836---
837Part of the linkgit:git[1] suite