diff mbox series

lib/oe/patch: avoid duplicated "From:" in generated patches

Message ID 20260710185207.3999639-2-yoann.congal@smile.fr
State New
Headers show
Series lib/oe/patch: avoid duplicated "From:" in generated patches | expand

Commit Message

Yoann Congal July 10, 2026, 6:52 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

To workaround issues with list.openembedded.org rewriting "From:" email
header, users are encouraged to put a "From:" header inside the mail
body. When using the suggested git-send-email workflow, users may use the
global git configs format.from=true and format.forceInBodyFrom=true:

man git-config:
> format.from
>    Provides the default value for the --from option to
>    format-patch. Accepts a boolean value, or a name and email
>    address. If false, format-patch defaults to --no-from, using
>    commit authors directly in the "From:" field of patch mails.
>    If true, format-patch defaults to --from, using your committer
>    identity in the "From:" field of patch mails and including a
>    "From:" field in the body of the patch mail if different. If
>    set to a non-boolean value, format-patch uses that value
>    instead of your committer identity. Defaults to false.
>
> format.forceInBodyFrom
>    Provides the default value for the --[no-]force-in-body-from
>    option to format-patch. Defaults to false.

With this configuration, devtool generated patches look like:
|From 4457b9d7805551e6b35efa25f998b63901d4bf86 Mon Sep 17 00:00:00 2001
|From: Yoann Congal <yoann.congal@smile.fr>
|Subject: [PATCH] Add a new line
|
|From: Original Author <author@example.org>
|
|[rest of the patch]
Notice the duplicated "From:" header.

To fix the double "From:" header, use the --no-from option for
git-format-patch to override this configuration and generate only one
"From: Original Author <...>" header.

Note: The "format.from" configuration is in git since v2.10 (in 2016),
and the --no-from option before that.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/lib/oe/patch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 1d50e83ab7a..0a201afe0ad 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -530,7 +530,7 @@  class GitApplyTree(PatchTree):
         patches = []
         try:
             for name, rev in startcommits.items():
-                cmd = ["git", "format-patch", "--no-signature", "--no-numbered", rev, "-o", tempdir]
+                cmd = ["git", "format-patch", "--no-from", "--no-signature", "--no-numbered", rev, "-o", tempdir]
                 if paths:
                     cmd.append('--')
                     cmd.extend(paths)