{"thread":{"id":"65315","subject":"[PATCH] Add a config option to add a comment to S-o-b lines","startedAt":"2026-03-20T10:29:04Z","lastAt":"2026-03-20T22:36:12Z","messageCount":4,"participants":["Uwe Kleine-König","Kristoffer Haugsbakk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"539507","messageId":"20260320102844.2714876-2-u.kleine-koenig@baylibre.com","threadId":"65315","inReplyTo":null,"subject":"[PATCH] Add a config option to add a comment to S-o-b lines","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@baylibre.com","sentAt":"2026-03-20T10:28:39Z","receivedAt":"2026-03-20T10:29:04Z","isPatch":true,"sender":{"key":"u.kleine-koenig@baylibre.com","avatar":null},"body":"As an employee of a consultant company I'm often requested to mention\nthe customer name in the Signed-off-by line. Add a config knob\n\"user.signoffcomment\" to configure this and use it in automatically\ngenerated S-o-b lines.\n\nSigned-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>\n---\n ident.c     | 26 ++++++++++++++++++++++----\n ident.h     |  3 ++-\n sequencer.c |  2 +-\n 3 files changed, 25 insertions(+), 6 deletions(-)\n\ndiff --git a/ident.c b/ident.c\nindex 0b7aacecd7d9..09c7823e8f29 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -20,6 +20,7 @@ static struct strbuf git_author_name = STRBUF_INIT;\n static struct strbuf git_author_email = STRBUF_INIT;\n static struct strbuf git_committer_name = STRBUF_INIT;\n static struct strbuf git_committer_email = STRBUF_INIT;\n+static struct strbuf git_sob_comment = STRBUF_INIT;\n static int default_email_is_bogus;\n static int default_name_is_bogus;\n \n@@ -468,7 +469,8 @@ const char *fmt_ident(const char *name, const char *email,\n \tif (!email) {\n \t\tif (whose_ident == WANT_AUTHOR_IDENT && git_author_email.len)\n \t\t\temail = git_author_email.buf;\n-\t\telse if (whose_ident == WANT_COMMITTER_IDENT && git_committer_email.len)\n+\t\telse if ((whose_ident == WANT_COMMITTER_IDENT || whose_ident == WANT_SOB_IDENT) &&\n+\t\t\t git_committer_email.len)\n \t\t\temail = git_committer_email.buf;\n \t}\n \tif (!email) {\n@@ -489,8 +491,9 @@ const char *fmt_ident(const char *name, const char *email,\n \t\tif (!name) {\n \t\t\tif (whose_ident == WANT_AUTHOR_IDENT && git_author_name.len)\n \t\t\t\tname = git_author_name.buf;\n-\t\t\telse if (whose_ident == WANT_COMMITTER_IDENT &&\n-\t\t\t\t\tgit_committer_name.len)\n+\t\t\telse if ((whose_ident == WANT_COMMITTER_IDENT ||\n+\t\t\t\t  whose_ident == WANT_SOB_IDENT) &&\n+\t\t\t\t git_committer_name.len)\n \t\t\t\tname = git_committer_name.buf;\n \t\t}\n \t\tif (!name) {\n@@ -523,7 +526,13 @@ const char *fmt_ident(const char *name, const char *email,\n \tstrbuf_reset(ident);\n \tif (want_name) {\n \t\tstrbuf_addstr_without_crud(ident, name);\n-\t\tstrbuf_addstr(ident, \" <\");\n+\t\tstrbuf_addstr(ident, \" \");\n+\t\tif (whose_ident == WANT_SOB_IDENT) {\n+\t\t\tstrbuf_addstr(ident, \"(\");\n+\t\t\tstrbuf_addstr_without_crud(ident, git_sob_comment.buf);\n+\t\t\tstrbuf_addstr(ident, \") \");\n+\t\t}\n+\t\tstrbuf_addstr(ident, \"<\");\n \t}\n \tstrbuf_addstr_without_crud(ident, email);\n \tif (want_name)\n@@ -554,6 +563,7 @@ const char *fmt_name(enum want_ident whose_ident)\n \t\temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \t\tbreak;\n \tcase WANT_COMMITTER_IDENT:\n+\tcase WANT_SOB_IDENT:\n \t\tname = getenv(\"GIT_COMMITTER_NAME\");\n \t\temail = getenv(\"GIT_COMMITTER_EMAIL\");\n \t\tbreak;\n@@ -671,6 +681,14 @@ static int set_ident(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"user.signoffcomment\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tstrbuf_reset(&git_sob_comment);\n+\t\tstrbuf_addstr(&git_sob_comment, value);\n+\t\treturn 0;\n+\t}\n+\n \treturn 0;\n }\n \ndiff --git a/ident.h b/ident.h\nindex 3c034038791b..bd3cd3e2655f 100644\n--- a/ident.h\n+++ b/ident.h\n@@ -21,7 +21,8 @@ struct ident_split {\n enum want_ident {\n \tWANT_BLANK_IDENT,\n \tWANT_AUTHOR_IDENT,\n-\tWANT_COMMITTER_IDENT\n+\tWANT_COMMITTER_IDENT,\n+\tWANT_SOB_IDENT,\n };\n \n const char *ident_default_name(void);\ndiff --git a/sequencer.c b/sequencer.c\nindex e5af49cecd08..37494b35c6ae 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5635,7 +5635,7 @@ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag)\n \tint has_footer;\n \n \tstrbuf_addstr(&sob, sign_off_header);\n-\tstrbuf_addstr(&sob, fmt_name(WANT_COMMITTER_IDENT));\n+\tstrbuf_addstr(&sob, fmt_name(WANT_SOB_IDENT));\n \tstrbuf_addch(&sob, '\\n');\n \n \tif (!ignore_footer)\n-- \n2.47.3\n\n"},{"id":"539510","messageId":"4333ce73-9c30-417f-95a4-356362488444@app.fastmail.com","threadId":"65315","inReplyTo":"20260320102844.2714876-2-u.kleine-koenig@baylibre.com","subject":"Re: [PATCH] Add a config option to add a comment to S-o-b lines","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-20T11:00:21Z","receivedAt":"2026-03-20T11:00:55Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Fri, Mar 20, 2026, at 11:28, Uwe Kleine-König wrote:\n> As an employee of a consultant company I'm often requested to mention\n> the customer name in the Signed-off-by line. Add a config knob\n\nAnd this is a widespread practice?\n\nLooking at the Linux Kernel there does seem to be a fair few hits.\n\n> \"user.signoffcomment\" to configure this and use it in automatically\n> generated S-o-b lines.\n>\n> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>\n> ---\n>[snip]\n\nWhat are the alternatives? I imagine that the commit-msg hook with\ngit-interpret-trailers(1) could do the same thing.\n\nAdding extra-ident data doesn’t seem to harmonize with grouping by\ntrailers (git-shortlog(1) with `--group=trailer:`) in the case where the\nsame person contributes under different orgs or something across the\nyears. The mailmap can’t be used for trailers. In that light should\ngit(1) implicitly encourage such a practice over the alternatives like a\nseparate trailer pre/post the `-by` trailer?\n\nI know it’s not the same thing—just an extension—but git-commit(1)\nnow says:\n\n    Git does not (and will not) have a configuration variable to enable\n    the --signoff command line option by default; see the commit.signoff\n    entry in gitfaq(7) for more details.\n\nThis does not configure a signoff but it does put more stuff on top of a\n“historical mistake”.\n"},{"id":"539569","messageId":"xmqq341ufn12.fsf@gitster.g","threadId":"65315","inReplyTo":"20260320102844.2714876-2-u.kleine-koenig@baylibre.com","subject":"Re: [PATCH] Add a config option to add a comment to S-o-b lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-20T17:06:49Z","receivedAt":"2026-03-20T17:06:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König <u.kleine-koenig@baylibre.com> writes:\n\n> As an employee of a consultant company I'm often requested to mention\n> the customer name in the Signed-off-by line. Add a config knob\n> \"user.signoffcomment\" to configure this and use it in automatically\n> generated S-o-b lines.\n>\n> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>\n> ---\n\nI know it is not the thrust of this patch, but I think you should\nthink about this question at the same time, eh, rather, I do not\nthink we want to add a feature like this without thinking things\nlike the following through:\n\nHow should this practice interact with commands like \"git log\n--author=\", \"git shortlog\", and friends?\n\nWould projects accepting contributions signed like so want to have a\nfeature to easily strip the comments without having to add new\nentries to their .mailmap every time a known contributor works for a\nnew client?\n\nAnd then there is a question of \"what shape of comment do we want?\nis it OK for us to dictate that it comes after the author's human\nreadable name identity enclosed in parentheses?\".\n\nShouldn't interpret-trailers be a good place to do this, instead of\na configuration option?\n\nThanks.\n"},{"id":"539580","messageId":"xmqq7br6dt7q.fsf@gitster.g","threadId":"65315","inReplyTo":"xmqq341ufn12.fsf@gitster.g","subject":"Re: [PATCH] Add a config option to add a comment to S-o-b lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-20T22:36:09Z","receivedAt":"2026-03-20T22:36:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Uwe Kleine-König <u.kleine-koenig@baylibre.com> writes:\n>\n>> As an employee of a consultant company I'm often requested to mention\n>> the customer name in the Signed-off-by line. Add a config knob\n>> \"user.signoffcomment\" to configure this and use it in automatically\n>> generated S-o-b lines.\n>>\n>> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>\n>> ---\n>\n> I know it is not the thrust of this patch, but I think you should\n> think about this question at the same time, eh, rather, I do not\n> think we want to add a feature like this without thinking things\n> like the following through:\n>\n> How should this practice interact with commands like \"git log\n> --author=\", \"git shortlog\", and friends?\n>\n> Would projects accepting contributions signed like so want to have a\n> feature to easily strip the comments without having to add new\n> entries to their .mailmap every time a known contributor works for a\n> new client?\n>\n> And then there is a question of \"what shape of comment do we want?\n> is it OK for us to dictate that it comes after the author's human\n> readable name identity enclosed in parentheses?\".\n>\n> Shouldn't interpret-trailers be a good place to do this, instead of\n> a configuration option?\n\nAnother tangent.  Stepping back a bit, these names and e-mail\naddresses come from:\n\n    [user]\n\tname = Uwe Kleine-König\n\temail = u.kleine-koenig@...\n\nIt is plausible that a single user may want to use different\nidentities depending on where the identities are used.  It may take\na form of three-level configuration variable name, i.e.,\n\n    user.<context>.name\n    user.<context>.email\n\nwhere obvious candidates for <context> are things like \"author\"\n(used for commit author ident), \"committer\", and \"tagger\".\n\nIt is not too inconceivable to have an entry dedicated for\n\"sign-off\", perhaps in addition to the above user.{name,email}\nentries you already have in your $HOME/.gitconfig, you may throw\nsomething like this in the project .git/config file:\n\n    [user \"sign-off\"]\n\tname = Uwe Kleine-König (Current Sponsor)\n\nident.c::fmt_ident() and ident.c::fmt_name() take \"enum want_ident\"\nthat lets our callers say \"I want AUTHOR_IDENT\" etc., and it would\nbe natural to extend the set of WANT_*_IDENT enumeration to support\nmore kind of names, if we really wanted to.\n\nHaving said that, wishing to be known under different identities to\ndifferent communities is one thing, but I am not yet convinced that\nit is a good idea to use different identities in a single project\ndepending where the ident appears.\n\nThanks.\n\n\n"}]}