git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Santi Béjar" <sbejar@gmail.com>
To: git@vger.kernel.org
Cc: "Santi Béjar" <sbejar@gmail.com>
Subject: [PATCHv4 4/4] user.warnautomatic: add config to control if the committer ident is shown
Date: Sun,  4 May 2008 18:04:52 +0200	[thread overview]
Message-ID: <1209917092-12146-5-git-send-email-sbejar@gmail.com> (raw)
In-Reply-To: <1209917092-12146-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        |   15 +++++++++++++--
 6 files changed, 25 insertions(+), 3 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 353f9c7..381e3c8 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -566,7 +566,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 				showed_ident++ ? "" : "#\n",
 				author_ident);
 
-		if (!user_explicit)
+		if (!user_explicit && user_warnautomatic)
 			fprintf(fp,
 				"%s"
 				"# Committer: %s\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 018060c..a63f9c4 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -166,14 +166,25 @@ test_expect_success 'author different from committer' '
 	test_cmp expect actual
 '
 
+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
-unset GIT_COMMITTER_EMAIL
-unset GIT_COMMITTER_NAME
 
 test_expect_success 'committer is automatic' '
 
+	git config --unset user.warnautomatic
 	echo >>negative &&
 	git commit -e -m "sample"
 	head -n 8 .git/COMMIT_EDITMSG |	\
-- 
1.5.5.1.224.gadb29

  parent reply	other threads:[~2008-05-04 16:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-04 16:04 [PATCHv4 0/4] Show author and/or committer in some cases Santi Béjar
2008-05-04 16:04 ` [PATCHv4 1/4] Preparation to call determine_author_info from prepare_to_commit Santi Béjar
2008-05-04 16:12   ` Santi Béjar
2008-05-04 16:04 ` [PATCHv4 2/4] commit: Show author if different from committer Santi Béjar
2008-05-06 23:34   ` Junio C Hamano
2008-05-04 16:04 ` [PATCHv4 3/4] commit: Show committer if automatic Santi Béjar
2008-05-04 16:04 ` Santi Béjar [this message]
2008-05-07 16:12   ` [PATCHv4 4/4] user.warnautomatic: add config to control if the committer ident is shown Junio C Hamano
2008-05-07 16:32     ` Santi Béjar
2008-05-04 16:25 ` [PATCHv4 0/4] Show author and/or committer in some cases Santi Béjar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1209917092-12146-5-git-send-email-sbejar@gmail.com \
    --to=sbejar@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).