diff mbox series

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

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

Commit Message

Yoann Congal July 18, 2026, 9:18 a.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

To workaround issues with groups.io/list.openembedded.org/lists.yoctoproject.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
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.

Putting those configuration locally in every groups.io related
repositories (That means every bitbake-setup repo setup) is tedious, to
avoid that the configuration can be made globally (e.g. in
~/.gitconfig):
 $ git config --global format.from true
 $ git config --global format.forceInBodyFrom true
... but then it applies to the devtool workspace.

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.
"--no-from" is the git global default, so this is a noop for users with
default configuration.

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>
---
Cc: Alexander Kanavin <alex.kanavin@gmail.com>
v1->v2:
* add more context in commit message following Alex's review:
  https://lore.kernel.org/all/20260710185207.3999639-2-yoann.congal@smile.fr/T/#mccc1ffe8c4e39a51924cc907857ae1e767632333
---
 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)