summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e83dbe8)
raw | patch | inline | side by side (parent: e83dbe8)
author | Santi Béjar <sbejar@gmail.com> | |
Sun, 4 May 2008 16:04:51 +0000 (18:04 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 May 2008 23:50:17 +0000 (16:50 -0700) |
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>
committer identity.
Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
cache.h | patch | blob | history | |
config.c | patch | blob | history | |
environment.c | patch | blob | history | |
ident.c | patch | blob | history | |
t/t7502-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index 4e51b9e354aab53de2a1fc721ab37b7da846c8da..a113eb0272438e60ca0af6dff441b9279cd2d133 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
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;
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;
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);
index d5d5dad1463e2251dc84cf0a85095a7e3e0eaeae..327e5eacd3191c115497d03dba079bba058cf2d8 100644 (file)
--- a/cache.h
+++ b/cache.h
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
extern char git_default_name[MAX_GITNAME];
+extern int user_ident_explicitly_given;
extern const char *git_commit_encoding;
extern const char *git_log_output_encoding;
diff --git a/config.c b/config.c
index b0ada515b9d839fc8691bc9af320353ff323b251..3bc4c7ed59dfdfc8c15c0066dd0b9fed57bfda04 100644 (file)
--- a/config.c
+++ b/config.c
if (!value)
return config_error_nonbool(var);
strlcpy(git_default_name, value, sizeof(git_default_name));
+ if (git_default_email[0])
+ user_ident_explicitly_given = 1;
return 0;
}
if (!value)
return config_error_nonbool(var);
strlcpy(git_default_email, value, sizeof(git_default_email));
+ if (git_default_name[0])
+ user_ident_explicitly_given = 1;
return 0;
}
diff --git a/environment.c b/environment.c
index fcd1ee5ef8c0999fce0095a2d6a792e5d221c50a..1b80036ca508c1a6d052abd9ea42224b95fdf69e 100644 (file)
--- a/environment.c
+++ b/environment.c
char git_default_email[MAX_GITNAME];
char git_default_name[MAX_GITNAME];
+int user_ident_explicitly_given;
int trust_executable_bit = 1;
int quote_path_fully = 1;
int has_symlinks = 1;
index ed44a5345a47d4843e8328c0f879ac925dde2b07..b35504a8d25594a8d243ae7490733eae5a262712 100644 (file)
--- a/ident.c
+++ b/ident.c
const char *git_committer_info(int flag)
{
+ if (getenv("GIT_COMMITTER_NAME") &&
+ getenv("GIT_COMMITTER_EMAIL"))
+ user_ident_explicitly_given = 1;
return fmt_ident(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL"),
getenv("GIT_COMMITTER_DATE"),
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 0b1db406a78333c771fc293c657c19a7ef1c7fc7..018060c60f590946c8e02181bfb1f572972bb787 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
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' '
+
+ echo >>negative &&
+ git commit -e -m "sample"
+ head -n 8 .git/COMMIT_EDITMSG | \
+ sed "s/^# Committer: .*/# Committer:/" >actual &&
+ test_cmp expect actual
+'
+
pwd=`pwd`
cat >> .git/FAKE_EDITOR << EOF
#! /bin/sh