public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add a config option to add a comment to S-o-b lines
@ 2026-03-20 10:28 Uwe Kleine-König
  2026-03-20 11:00 ` Kristoffer Haugsbakk
  2026-03-20 17:06 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-03-20 10:28 UTC (permalink / raw)
  To: git

As an employee of a consultant company I'm often requested to mention
the customer name in the Signed-off-by line. Add a config knob
"user.signoffcomment" to configure this and use it in automatically
generated S-o-b lines.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 ident.c     | 26 ++++++++++++++++++++++----
 ident.h     |  3 ++-
 sequencer.c |  2 +-
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/ident.c b/ident.c
index 0b7aacecd7d9..09c7823e8f29 100644
--- a/ident.c
+++ b/ident.c
@@ -20,6 +20,7 @@ static struct strbuf git_author_name = STRBUF_INIT;
 static struct strbuf git_author_email = STRBUF_INIT;
 static struct strbuf git_committer_name = STRBUF_INIT;
 static struct strbuf git_committer_email = STRBUF_INIT;
+static struct strbuf git_sob_comment = STRBUF_INIT;
 static int default_email_is_bogus;
 static int default_name_is_bogus;
 
@@ -468,7 +469,8 @@ const char *fmt_ident(const char *name, const char *email,
 	if (!email) {
 		if (whose_ident == WANT_AUTHOR_IDENT && git_author_email.len)
 			email = git_author_email.buf;
-		else if (whose_ident == WANT_COMMITTER_IDENT && git_committer_email.len)
+		else if ((whose_ident == WANT_COMMITTER_IDENT || whose_ident == WANT_SOB_IDENT) &&
+			 git_committer_email.len)
 			email = git_committer_email.buf;
 	}
 	if (!email) {
@@ -489,8 +491,9 @@ const char *fmt_ident(const char *name, const char *email,
 		if (!name) {
 			if (whose_ident == WANT_AUTHOR_IDENT && git_author_name.len)
 				name = git_author_name.buf;
-			else if (whose_ident == WANT_COMMITTER_IDENT &&
-					git_committer_name.len)
+			else if ((whose_ident == WANT_COMMITTER_IDENT ||
+				  whose_ident == WANT_SOB_IDENT) &&
+				 git_committer_name.len)
 				name = git_committer_name.buf;
 		}
 		if (!name) {
@@ -523,7 +526,13 @@ const char *fmt_ident(const char *name, const char *email,
 	strbuf_reset(ident);
 	if (want_name) {
 		strbuf_addstr_without_crud(ident, name);
-		strbuf_addstr(ident, " <");
+		strbuf_addstr(ident, " ");
+		if (whose_ident == WANT_SOB_IDENT) {
+			strbuf_addstr(ident, "(");
+			strbuf_addstr_without_crud(ident, git_sob_comment.buf);
+			strbuf_addstr(ident, ") ");
+		}
+		strbuf_addstr(ident, "<");
 	}
 	strbuf_addstr_without_crud(ident, email);
 	if (want_name)
@@ -554,6 +563,7 @@ const char *fmt_name(enum want_ident whose_ident)
 		email = getenv("GIT_AUTHOR_EMAIL");
 		break;
 	case WANT_COMMITTER_IDENT:
+	case WANT_SOB_IDENT:
 		name = getenv("GIT_COMMITTER_NAME");
 		email = getenv("GIT_COMMITTER_EMAIL");
 		break;
@@ -671,6 +681,14 @@ static int set_ident(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "user.signoffcomment")) {
+		if (!value)
+			return config_error_nonbool(var);
+		strbuf_reset(&git_sob_comment);
+		strbuf_addstr(&git_sob_comment, value);
+		return 0;
+	}
+
 	return 0;
 }
 
diff --git a/ident.h b/ident.h
index 3c034038791b..bd3cd3e2655f 100644
--- a/ident.h
+++ b/ident.h
@@ -21,7 +21,8 @@ struct ident_split {
 enum want_ident {
 	WANT_BLANK_IDENT,
 	WANT_AUTHOR_IDENT,
-	WANT_COMMITTER_IDENT
+	WANT_COMMITTER_IDENT,
+	WANT_SOB_IDENT,
 };
 
 const char *ident_default_name(void);
diff --git a/sequencer.c b/sequencer.c
index e5af49cecd08..37494b35c6ae 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5635,7 +5635,7 @@ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag)
 	int has_footer;
 
 	strbuf_addstr(&sob, sign_off_header);
-	strbuf_addstr(&sob, fmt_name(WANT_COMMITTER_IDENT));
+	strbuf_addstr(&sob, fmt_name(WANT_SOB_IDENT));
 	strbuf_addch(&sob, '\n');
 
 	if (!ignore_footer)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-20 22:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 10:28 [PATCH] Add a config option to add a comment to S-o-b lines Uwe Kleine-König
2026-03-20 11:00 ` Kristoffer Haugsbakk
2026-03-20 17:06 ` Junio C Hamano
2026-03-20 22:36   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox