aboutsummaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorSanti Béjar <sbejar@gmail.com>2008-05-04 18:04:51 +0200
committerJunio C Hamano <gitster@pobox.com>2008-05-06 16:50:17 -0700
commitbb1ae3f6fff19b0a1ab1bb6a815d26d39b9f15e6 (patch)
treed11c7e3846690f745e8c6998d56464f21a23e3c9 /builtin-commit.c
parente83dbe802f24e017f2e3889272a70793c064d984 (diff)
downloadgit-bb1ae3f6fff19b0a1ab1bb6a815d26d39b9f15e6.tar.gz
git-bb1ae3f6fff19b0a1ab1bb6a815d26d39b9f15e6.tar.xz
commit: Show committer if automatic
To warn the user in case he/she might be using an unintended committer identity. Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index 4e51b9e35..a113eb027 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -446,6 +446,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
FILE *fp;
const char *hook_arg1 = NULL;
const char *hook_arg2 = NULL;
+ int ident_shown = 0;
if (!no_verify && run_hook(index_file, "pre-commit", NULL))
return 0;
@@ -527,6 +528,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
determine_author_info();
+ /* This checks if committer ident is explicitly given */
+ git_committer_info(0);
if (use_editor) {
char *author_ident;
const char *committer_ident;
@@ -558,12 +561,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
getenv("GIT_COMMITTER_EMAIL"));
if (strcmp(author_ident, committer_ident))
fprintf(fp,
- "#\n"
- "# Author: %s\n"
- "#\n",
+ "%s"
+ "# Author: %s\n",
+ ident_shown++ ? "" : "#\n",
author_ident);
free(author_ident);
+ if (!user_ident_explicitly_given)
+ fprintf(fp,
+ "%s"
+ "# Committer: %s\n",
+ ident_shown++ ? "" : "#\n",
+ committer_ident);
+
+ if (ident_shown)
+ fprintf(fp, "#\n");
+
saved_color_setting = wt_status_use_color;
wt_status_use_color = 0;
commitable = run_status(fp, index_file, prefix, 1);