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

[PATCH 2/2] user.warnautomatic: add config to control if the committer ident is shown

From
SBSanti Béjar <sbejar@gmail.com>
Date
May 2, 2008, 18:22 UTC
Message-ID
<1209752541-19111-3-git-send-email-sbejar@gmail.com>
In-Reply-To
<1209752541-19111-1-git-send-email-sbejar@gmail.com>
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
 Documentation/config.txt |    4 ++++
 builtin-commit.c         |    2 +-
 cache.h                  |    1 +
 config.c                 |    5 +++++
 environment.c            |    1 +
 t/t7502-commit.sh        |   22 ++++++++++++++++++----
 6 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 824e416..9c770a6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -994,6 +994,10 @@ user.signingkey::
 	unchanged to gpg's --local-user parameter, so you may specify a key
 	using any method that gpg supports.
 
+user.warnautomatic::
+	A boolean to show the committer ident while committing in the editor
+	if it is set automatically. Defaults to true.
+
 whatchanged.difftree::
 	The default linkgit:git-diff-tree[1] arguments to be used
 	for linkgit:git-whatchanged[1].
diff --git a/builtin-commit.c b/builtin-commit.c
index b7cc382..7ab8b40 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -588,7 +588,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 				showed_ident++ ? "" : "#\n",
 				fmt_name(author_name, author_email));
 
-		if (!user_explicit)
+		if (!user_explicit && user_warnautomatic)
 			fprintf(fp,
 				"%s# Committer: %s\n",
 				showed_ident++ ? "" : "#\n",
diff --git a/cache.h b/cache.h
index e8b26cf..5d0dd23 100644
--- a/cache.h
+++ b/cache.h
@@ -719,6 +719,7 @@ extern int config_error_nonbool(const char *);
 extern char git_default_email[MAX_GITNAME];
 extern char git_default_name[MAX_GITNAME];
 extern int user_explicit;
+extern int user_warnautomatic;
 
 extern const char *git_commit_encoding;
 extern const char *git_log_output_encoding;
diff --git a/config.c b/config.c
index e49804a..1588053 100644
--- a/config.c
+++ b/config.c
@@ -457,6 +457,11 @@ int git_default_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "user.warnautomatic")) {
+		user_warnautomatic = git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "i18n.commitencoding"))
 		return git_config_string(&git_commit_encoding, var, value);
 
diff --git a/environment.c b/environment.c
index b941971..6b6ede6 100644
--- a/environment.c
+++ b/environment.c
@@ -12,6 +12,7 @@
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
 int user_explicit = 0;
+int user_warnautomatic = 1;
 int trust_executable_bit = 1;
 int quote_path_fully = 1;
 int has_symlinks = 1;
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 8f65c39..a63f9c4 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -155,25 +155,39 @@ test_expect_success 'cleanup commit messages (strip,-F,-e)' '
 '
 
 echo "#
-# Author:    $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" >> expect
+# Author:    $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+#" >> expect
 
 test_expect_success 'author different from committer' '
 
 	echo >>negative &&
 	git commit -e -m "sample"
-	head -n 6 .git/COMMIT_EDITMSG >actual &&
+	head -n 7 .git/COMMIT_EDITMSG >actual &&
 	test_cmp expect actual
 '
 
-echo "# Committer:" >> expect
 unset GIT_COMMITTER_EMAIL
 unset GIT_COMMITTER_NAME
 
+test_expect_success 'committer is automatic but user.warnautomatic=no' '
+
+	git config user.warnautomatic no
+	echo >>negative &&
+	git commit -e -m "sample"
+	head -n 7 .git/COMMIT_EDITMSG >actual &&
+	test_cmp expect actual
+'
+
+sed -i '$d' expect
+echo "# Committer:
+#" >> expect
+
 test_expect_success 'committer is automatic' '
 
+	git config --unset user.warnautomatic
 	echo >>negative &&
 	git commit -e -m "sample"
-	head -n 7 .git/COMMIT_EDITMSG |	\
+	head -n 8 .git/COMMIT_EDITMSG |	\
 	sed "s/^# Committer: .*/# Committer:/" >actual &&
 	test_cmp expect actual
 '
-- 
1.5.5.1.223.g2532
Previous: Santi BéjarNext: Junio C Hamano
Message 5 of 11 in “Show committer ident in some cases”
  1. 0/2 Show committer ident in some casesSanti Béjar, May 2, 2008
  2. 1/2 commit: Show committer if automaticSanti Béjar, May 2, 2008
  3. Junio C HamanoMay 3, 2008
  4. Santi BéjarMay 3, 2008
  5. 2/2 user.warnautomatic: add config to control if the committer ident is shownSanti Béjar, May 2, 2008
  6. Junio C HamanoMay 2, 2008
  7. Santi BéjarMay 2, 2008
  8. Junio C HamanoMay 2, 2008
  9. Santi BéjarMay 3, 2008
  10. Jeff KingMay 5, 2008
  11. Junio C HamanoMay 5, 2008

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.