Home Explore Blog CI



git

8th chunk of `Documentation/git-format-patch.adoc`
3999ea3e83dfe99842b8896921945f0a384d0b0dc09c5aca0000000100000fa1
 complain that
  the patch does not apply.  Look in the .git/rebase-apply/ subdirectory and
  see what 'patch' file contains and check for the common
  corruption patterns mentioned above.

* While at it, check the 'info' and 'final-commit' files as well.
  If what is in 'final-commit' is not exactly what you would want to
  see in the commit log message, it is very likely that the
  receiver would end up hand editing the log message when applying
  your patch.  Things like "Hi, this is my first patch.\n" in the
  patch e-mail should come after the three-dash line that signals
  the end of the commit message.

MUA-SPECIFIC HINTS
------------------
Here are some hints on how to successfully submit patches inline using
various mailers.

GMail
~~~~~
GMail does not have any way to turn off line wrapping in the web
interface, so it will mangle any emails that you send.  You can however
use "git send-email" and send your patches through the GMail SMTP server, or
use any IMAP email client to connect to the google IMAP server and forward
the emails through that.

For hints on using 'git send-email' to send your patches through the
GMail SMTP server, see the EXAMPLE section of linkgit:git-send-email[1].

For hints on submission using the IMAP interface, see the EXAMPLE
section of linkgit:git-imap-send[1].

Thunderbird
~~~~~~~~~~~
By default, Thunderbird will both wrap emails as well as flag
them as being 'format=flowed', both of which will make the
resulting email unusable by Git.

There are three different approaches: use an add-on to turn off line wraps,
configure Thunderbird to not mangle patches, or use
an external editor to keep Thunderbird from mangling the patches.

Approach #1 (add-on)
^^^^^^^^^^^^^^^^^^^^

Install the Toggle Word Wrap add-on that is available from
https://addons.mozilla.org/thunderbird/addon/toggle-word-wrap/
It adds a menu entry "Enable Word Wrap" in the composer's "Options" menu
that you can tick off. Now you can compose the message as you otherwise do
(cut + paste, 'git format-patch' | 'git imap-send', etc), but you have to
insert line breaks manually in any text that you type.

Approach #2 (configuration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Three steps:

1. Configure your mail server composition as plain text:
   Edit...Account Settings...Composition & Addressing,
   uncheck "Compose Messages in HTML".

2. Configure your general composition window to not wrap.
+
In Thunderbird 2:
Edit..Preferences..Composition, wrap plain text messages at 0
+
In Thunderbird 3:
Edit..Preferences..Advanced..Config Editor.  Search for
"mail.wrap_long_lines".
Toggle it to make sure it is set to `false`. Also, search for
"mailnews.wraplength" and set the value to 0.

3. Disable the use of format=flowed:
   Edit..Preferences..Advanced..Config Editor.  Search for
   "mailnews.send_plaintext_flowed".
   Toggle it to make sure it is set to `false`.

After that is done, you should be able to compose email as you
otherwise would (cut + paste, 'git format-patch' | 'git imap-send', etc),
and the patches will not be mangled.

Approach #3 (external editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following Thunderbird extensions are needed:
AboutConfig from https://mjg.github.io/AboutConfig/ and
External Editor from https://globs.org/articles.php?lng=en&pg=8

1. Prepare the patch as a text file using your method of choice.

2. Before opening a compose window, use Edit->Account Settings to
   uncheck the "Compose messages in HTML format" setting in the
   "Composition & Addressing" panel of the account to be used to
   send the patch.

3. In the main Thunderbird window, 'before' you open the compose
   window for the patch, use Tools->about:config to set the
   following to the indicated values:
+
----------
	mailnews.send_plaintext_flowed  => false
	mailnews.wraplength             => 0
----------

4. Open a compose window and click the external editor icon.

5. In the external editor window, read in the patch file and exit
   the editor normally.

Side

Title: Troubleshooting Patch Application and MUA Configuration
Summary
When applying patches, if Git complains that the patch does not apply, troubleshoot by checking the 'patch' file in the .git/rebase-apply/ subdirectory for corruption patterns; also, configure your Mail User Agent (MUA) correctly to avoid mangling patches, with specific hints provided for Gmail and Thunderbird, including using 'git send-email' or external editors to prevent format corruption.