git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit: Add commit.signoff configuration option

From
Chris Down <chris@chrisdown.name>
Date
May 13, 2025, 12:20 UTC
Message-ID
<aCM5JY25NVPgyYRP@chrisdown.name>

Introduce a new `commit.signoff` config variable that mirrors the behavior of the -s/--signoff flag.

We already have prior art in format-patch with `format.signoff`; this brings parity for those who don’t use a patch-based workflow but still rely on signoffs.

Right now people who have to do this regularly often alias commit to `commit --signoff` in their shell, which is less than ideal -- this config option avoids having to do that.

Signed-off-by: Chris Down <chris@chrisdown.name>
---
 Documentation/signoff-option.adoc         |  4 ++++
 builtin/commit.c                          |  4 ++++
 t/t7500-commit-template-squash-signoff.sh | 10 ++++++++++
 3 files changed, 18 insertions(+)
diff --git a/Documentation/signoff-option.adoc b/Documentation/signoff-option.adoc
index cddfb225d1..0055874e84 100644
--- a/Documentation/signoff-option.adoc
+++ b/Documentation/signoff-option.adoc
@@ -13,6 +13,10 @@ endif::git-commit[]
 	Linux kernel and Git projects.)  Consult the documentation or
 	leadership of the project to which you're contributing to
 	understand how the signoffs are used in that project.
+ifdef::git-commit[]
+	The `commit.signoff` configuration variable may also be used to imply
+	`--signoff`.
+endif::git-commit[]
 +
 The `--no-signoff` option can be used to countermand an earlier `--signoff`
 option on the command line.
diff --git a/builtin/commit.c b/builtin/commit.c
index 66bd91fd52..da98895438 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1670,6 +1670,10 @@ static int git_commit_config(const char *k, const char *v,
 							       &is_bool);
 		return 0;
 	}
+	if (!strcmp(k, "commit.signoff")) {
+		signoff = git_config_bool(k, v);
+		return 0;
+	}
 
 	return git_status_config(k, v, ctx, s);
 }
diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 4dca8d97a7..03c20dcb1d 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -181,6 +181,16 @@ test_expect_success '--signoff' '
 	test_cmp expect output
 '
 
+test_expect_success 'config commit.signoff implies signoff' '
+	git config commit.signoff true &&
+	echo "871119" >> bar &&
+	git add bar &&
+	echo "zort" | git commit -F - bar &&
+	git cat-file commit HEAD | sed "1,/^\$/d" > output &&
+	test_cmp expect output &&
+	git config --unset commit.signoff
+'
+
 test_expect_success 'commit message from file (1)' '
 	mkdir subdir &&
 	echo "Log in top directory" >log &&
-- 
2.49.0
Next: Kristoffer Haugsbakk
Message 1 of 14 in “commit: Add commit.signoff configuration option”
  1. commit: Add commit.signoff configuration optionChris Down, May 13, 2025
  2. Kristoffer HaugsbakkMay 13, 2025
  3. D. Ben KnobleMay 13, 2025
  4. Chris DownMay 14, 2025
  5. Junio C HamanoMay 15, 2025
  6. Chris DownMay 15, 2025
  7. Junio C HamanoMay 16, 2025
  8. Chris DownMay 16, 2025
  9. Chris DownJun 3, 2025
  10. Junio C HamanoJun 4, 2025
  11. Collin FunkJun 5, 2025
  12. Chris DownJun 9, 2025
  13. Ben KnobleMay 16, 2025
  14. Chris DownMay 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.