{"thread":{"id":"13373","subject":"[PATCHv4 0/4] Show author and/or committer in some cases","startedAt":"2008-05-04T16:04:48Z","lastAt":"2008-05-07T16:32:24Z","messageCount":10,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76020","messageId":"1209917092-12146-1-git-send-email-sbejar@gmail.com","threadId":"13373","inReplyTo":null,"subject":"[PATCHv4 0/4] Show author and/or committer in some cases","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:04:48Z","receivedAt":"2008-05-04T16:04:48Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n  This patch series tries to make more evident the author and committer ident\nin case the user might be using an unintended author/committer identity.\n\nSanti\n\nSanti Béjar (4):\n  Preparation to call determine_author_info from prepare_to_commit\n  commit: Show author if different from committer\n  commit: Show committer if automatic\n  user.warnautomatic: add config to control if the committer ident is\n    shown\n\n Documentation/config.txt |    4 ++\n builtin-commit.c         |  112 +++++++++++++++++++++++++++++----------------\n cache.h                  |    2 +\n config.c                 |    9 ++++\n environment.c            |    2 +\n ident.c                  |    3 +\n t/t7502-commit.sh        |   38 ++++++++++++++++\n 7 files changed, 130 insertions(+), 40 deletions(-)\n"},{"id":"76022","messageId":"1209917092-12146-2-git-send-email-sbejar@gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-1-git-send-email-sbejar@gmail.com","subject":"[PATCHv4 1/4] Preparation to call determine_author_info from prepare_to_commit","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:04:49Z","receivedAt":"2008-05-04T16:04:49Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"From: Santi Béjar <sbjear@gmail.com>\n\nReorder functions definitions such that determine_author_info is\ndefined before prepare_to_commit. No code changes.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n builtin-commit.c |   78 +++++++++++++++++++++++++++---------------------------\n 1 files changed, 39 insertions(+), 39 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 256181a..a37d8c3 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -395,6 +395,45 @@ static int is_a_merge(const unsigned char *sha1)\n \n static const char sign_off_header[] = \"Signed-off-by: \";\n \n+static void determine_author_info(struct strbuf *sb)\n+{\n+\tchar *name, *email, *date;\n+\n+\tname = getenv(\"GIT_AUTHOR_NAME\");\n+\temail = getenv(\"GIT_AUTHOR_EMAIL\");\n+\tdate = getenv(\"GIT_AUTHOR_DATE\");\n+\n+\tif (use_message) {\n+\t\tconst char *a, *lb, *rb, *eol;\n+\n+\t\ta = strstr(use_message_buffer, \"\\nauthor \");\n+\t\tif (!a)\n+\t\t\tdie(\"invalid commit: %s\", use_message);\n+\n+\t\tlb = strstr(a + 8, \" <\");\n+\t\trb = strstr(a + 8, \"> \");\n+\t\teol = strchr(a + 8, '\\n');\n+\t\tif (!lb || !rb || !eol)\n+\t\t\tdie(\"invalid commit: %s\", use_message);\n+\n+\t\tname = xstrndup(a + 8, lb - (a + 8));\n+\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n+\t\tdate = xstrndup(rb + 2, eol - (rb + 2));\n+\t}\n+\n+\tif (force_author) {\n+\t\tconst char *lb = strstr(force_author, \" <\");\n+\t\tconst char *rb = strchr(force_author, '>');\n+\n+\t\tif (!lb || !rb)\n+\t\t\tdie(\"malformed --author parameter\");\n+\t\tname = xstrndup(force_author, lb - force_author);\n+\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n+\t}\n+\n+\tstrbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n+}\n+\n static int prepare_to_commit(const char *index_file, const char *prefix)\n {\n \tstruct stat statbuf;\n@@ -622,45 +661,6 @@ static int message_is_empty(struct strbuf *sb, int start)\n \treturn 1;\n }\n \n-static void determine_author_info(struct strbuf *sb)\n-{\n-\tchar *name, *email, *date;\n-\n-\tname = getenv(\"GIT_AUTHOR_NAME\");\n-\temail = getenv(\"GIT_AUTHOR_EMAIL\");\n-\tdate = getenv(\"GIT_AUTHOR_DATE\");\n-\n-\tif (use_message) {\n-\t\tconst char *a, *lb, *rb, *eol;\n-\n-\t\ta = strstr(use_message_buffer, \"\\nauthor \");\n-\t\tif (!a)\n-\t\t\tdie(\"invalid commit: %s\", use_message);\n-\n-\t\tlb = strstr(a + 8, \" <\");\n-\t\trb = strstr(a + 8, \"> \");\n-\t\teol = strchr(a + 8, '\\n');\n-\t\tif (!lb || !rb || !eol)\n-\t\t\tdie(\"invalid commit: %s\", use_message);\n-\n-\t\tname = xstrndup(a + 8, lb - (a + 8));\n-\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n-\t\tdate = xstrndup(rb + 2, eol - (rb + 2));\n-\t}\n-\n-\tif (force_author) {\n-\t\tconst char *lb = strstr(force_author, \" <\");\n-\t\tconst char *rb = strchr(force_author, '>');\n-\n-\t\tif (!lb || !rb)\n-\t\t\tdie(\"malformed --author parameter\");\n-\t\tname = xstrndup(force_author, lb - force_author);\n-\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n-\t}\n-\n-\tstrbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n-}\n-\n static int parse_and_validate_options(int argc, const char *argv[],\n \t\t\t\t      const char * const usage[])\n {\n-- \n1.5.5.1.224.gadb29\n"},{"id":"76021","messageId":"1209917092-12146-3-git-send-email-sbejar@gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-1-git-send-email-sbejar@gmail.com","subject":"[PATCHv4 2/4] commit: Show author if different from committer","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:04:50Z","receivedAt":"2008-05-04T16:04:50Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"That would help reassure anybody while committing other's changes.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n builtin-commit.c  |   25 ++++++++++++++++++++++---\n t/t7502-commit.sh |   12 ++++++++++++\n 2 files changed, 34 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex a37d8c3..d03b6b2 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -47,6 +47,7 @@ static enum {\n \n static char *logfile, *force_author, *template_file;\n static char *edit_message, *use_message;\n+static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n static int quiet, verbose, untracked_files, no_verify, allow_empty;\n /*\n@@ -395,7 +396,7 @@ static int is_a_merge(const unsigned char *sha1)\n \n static const char sign_off_header[] = \"Signed-off-by: \";\n \n-static void determine_author_info(struct strbuf *sb)\n+static void determine_author_info()\n {\n \tchar *name, *email, *date;\n \n@@ -431,7 +432,9 @@ static void determine_author_info(struct strbuf *sb)\n \t\temail = xstrndup(lb + 2, rb - (lb + 2));\n \t}\n \n-\tstrbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n+\tauthor_name = name;\n+\tauthor_email = email;\n+\tauthor_date = date;\n }\n \n static int prepare_to_commit(const char *index_file, const char *prefix)\n@@ -443,6 +446,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \tFILE *fp;\n \tconst char *hook_arg1 = NULL;\n \tconst char *hook_arg2 = NULL;\n+\tconst char *author_ident;\n+\tconst char *committer_ident;\n \n \tif (!no_verify && run_hook(index_file, \"pre-commit\", NULL))\n \t\treturn 0;\n@@ -522,6 +527,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \n \tstrbuf_release(&sb);\n \n+\tdetermine_author_info();\n+\n \tif (use_editor) {\n \t\tif (in_merge)\n \t\t\tfprintf(fp,\n@@ -545,6 +552,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \t\tif (only_include_assumed)\n \t\t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n \n+\t\tauthor_ident = xstrdup(fmt_name(author_name, author_email));\n+\t\tcommitter_ident =\n+\t\t\txstrdup(fmt_name(getenv(\"GIT_COMMITTER_NAME\"),\n+\t\t\t\t\t getenv(\"GIT_COMMITTER_EMAIL\")));\n+\t\tif (strcmp(author_ident, committer_ident))\n+\t\t\tfprintf(fp,\n+\t\t\t\t\"#\\n\"\n+\t\t\t\t\"# Author:    %s\\n\"\n+\t\t\t\t\"#\\n\",\n+\t\t\t\tauthor_ident);\n+\n \t\tsaved_color_setting = wt_status_use_color;\n \t\twt_status_use_color = 0;\n \t\tcommitable = run_status(fp, index_file, prefix, 1);\n@@ -920,7 +938,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tstrbuf_addf(&sb, \"parent %s\\n\", sha1_to_hex(head_sha1));\n \t}\n \n-\tdetermine_author_info(&sb);\n+\tstrbuf_addf(&sb, \"author %s\\n\",\n+\t\t    fmt_ident(author_name, author_email, author_date, IDENT_ERROR_ON_NO_NAME));\n \tstrbuf_addf(&sb, \"committer %s\\n\", git_committer_info(IDENT_ERROR_ON_NO_NAME));\n \tif (!is_encoding_utf8(git_commit_encoding))\n \t\tstrbuf_addf(&sb, \"encoding %s\\n\", git_commit_encoding);\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex 284c941..0b1db40 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -154,6 +154,18 @@ test_expect_success 'cleanup commit messages (strip,-F,-e)' '\n \n '\n \n+echo \"#\n+# Author:    $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n+#\" >> expect\n+\n+test_expect_success 'author different from committer' '\n+\n+\techo >>negative &&\n+\tgit commit -e -m \"sample\"\n+\thead -n 7 .git/COMMIT_EDITMSG >actual &&\n+\ttest_cmp expect actual\n+'\n+\n pwd=`pwd`\n cat >> .git/FAKE_EDITOR << EOF\n #! /bin/sh\n-- \n1.5.5.1.224.gadb29\n"},{"id":"76024","messageId":"1209917092-12146-4-git-send-email-sbejar@gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-1-git-send-email-sbejar@gmail.com","subject":"[PATCHv4 3/4] commit: Show committer if automatic","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:04:51Z","receivedAt":"2008-05-04T16:04:51Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"To warn the user in case he/she might be using an unintended\ncommitter identity.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n builtin-commit.c  |   19 ++++++++++++++++---\n cache.h           |    1 +\n config.c          |    4 ++++\n environment.c     |    1 +\n ident.c           |    3 +++\n t/t7502-commit.sh |   15 +++++++++++++++\n 6 files changed, 40 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex d03b6b2..353f9c7 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -448,6 +448,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \tconst char *hook_arg2 = NULL;\n \tconst char *author_ident;\n \tconst char *committer_ident;\n+\tint showed_ident = 0;\n \n \tif (!no_verify && run_hook(index_file, \"pre-commit\", NULL))\n \t\treturn 0;\n@@ -528,6 +529,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \tstrbuf_release(&sb);\n \n \tdetermine_author_info();\n+\t/* To know if the committer ident is automatic */\n+\tgit_committer_info(0);\n \n \tif (use_editor) {\n \t\tif (in_merge)\n@@ -558,11 +561,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \t\t\t\t\t getenv(\"GIT_COMMITTER_EMAIL\")));\n \t\tif (strcmp(author_ident, committer_ident))\n \t\t\tfprintf(fp,\n-\t\t\t\t\"#\\n\"\n-\t\t\t\t\"# Author:    %s\\n\"\n-\t\t\t\t\"#\\n\",\n+\t\t\t\t\"%s\"\n+\t\t\t\t\"# Author:    %s\\n\",\n+\t\t\t\tshowed_ident++ ? \"\" : \"#\\n\",\n \t\t\t\tauthor_ident);\n \n+\t\tif (!user_explicit)\n+\t\t\tfprintf(fp,\n+\t\t\t\t\"%s\"\n+\t\t\t\t\"# Committer: %s\\n\",\n+\t\t\t\tshowed_ident++ ? \"\" : \"#\\n\",\n+\t\t\t\tcommitter_ident);\n+\n+\t\tif (showed_ident)\n+\t\t\tfprintf(fp, \"#\\n\");\n+\n \t\tsaved_color_setting = wt_status_use_color;\n \t\twt_status_use_color = 0;\n \t\tcommitable = run_status(fp, index_file, prefix, 1);\ndiff --git a/cache.h b/cache.h\nindex 5a28ddd..e8b26cf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -718,6 +718,7 @@ extern int config_error_nonbool(const char *);\n #define MAX_GITNAME (1000)\n extern char git_default_email[MAX_GITNAME];\n extern char git_default_name[MAX_GITNAME];\n+extern int user_explicit;\n \n extern const char *git_commit_encoding;\n extern const char *git_log_output_encoding;\ndiff --git a/config.c b/config.c\nindex b0ada51..e49804a 100644\n--- a/config.c\n+++ b/config.c\n@@ -443,6 +443,8 @@ int git_default_config(const char *var, const char *value)\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n \t\tstrlcpy(git_default_name, value, sizeof(git_default_name));\n+\t\tif (git_default_email[0])\n+\t\t\tuser_explicit = 1;\n \t\treturn 0;\n \t}\n \n@@ -450,6 +452,8 @@ int git_default_config(const char *var, const char *value)\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n \t\tstrlcpy(git_default_email, value, sizeof(git_default_email));\n+\t\tif (git_default_name[0])\n+\t\t\tuser_explicit = 1;\n \t\treturn 0;\n \t}\n \ndiff --git a/environment.c b/environment.c\nindex 6739a3f..b941971 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -11,6 +11,7 @@\n \n char git_default_email[MAX_GITNAME];\n char git_default_name[MAX_GITNAME];\n+int user_explicit = 0;\n int trust_executable_bit = 1;\n int quote_path_fully = 1;\n int has_symlinks = 1;\ndiff --git a/ident.c b/ident.c\nindex ed44a53..67ccbf3 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -250,6 +250,9 @@ const char *git_author_info(int flag)\n \n const char *git_committer_info(int flag)\n {\n+\tif (getenv(\"GIT_COMMITTER_NAME\") &&\n+\t    getenv(\"GIT_COMMITTER_EMAIL\"))\n+\t\tuser_explicit = 1;\n \treturn fmt_ident(getenv(\"GIT_COMMITTER_NAME\"),\n \t\t\t getenv(\"GIT_COMMITTER_EMAIL\"),\n \t\t\t getenv(\"GIT_COMMITTER_DATE\"),\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex 0b1db40..018060c 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -166,6 +166,21 @@ test_expect_success 'author different from committer' '\n \ttest_cmp expect actual\n '\n \n+sed -i '$d' expect\n+echo \"# Committer:\n+#\" >> expect\n+unset GIT_COMMITTER_EMAIL\n+unset GIT_COMMITTER_NAME\n+\n+test_expect_success 'committer is automatic' '\n+\n+\techo >>negative &&\n+\tgit commit -e -m \"sample\"\n+\thead -n 8 .git/COMMIT_EDITMSG |\t\\\n+\tsed \"s/^# Committer: .*/# Committer:/\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n pwd=`pwd`\n cat >> .git/FAKE_EDITOR << EOF\n #! /bin/sh\n-- \n1.5.5.1.224.gadb29\n"},{"id":"76023","messageId":"1209917092-12146-5-git-send-email-sbejar@gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-1-git-send-email-sbejar@gmail.com","subject":"[PATCHv4 4/4] user.warnautomatic: add config to control if the committer ident is shown","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:04:52Z","receivedAt":"2008-05-04T16:04:52Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/config.txt |    4 ++++\n builtin-commit.c         |    2 +-\n cache.h                  |    1 +\n config.c                 |    5 +++++\n environment.c            |    1 +\n t/t7502-commit.sh        |   15 +++++++++++++--\n 6 files changed, 25 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 824e416..9c770a6 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -994,6 +994,10 @@ user.signingkey::\n \tunchanged to gpg's --local-user parameter, so you may specify a key\n \tusing any method that gpg supports.\n \n+user.warnautomatic::\n+\tA boolean to show the committer ident while committing in the editor\n+\tif it is set automatically. Defaults to true.\n+\n whatchanged.difftree::\n \tThe default linkgit:git-diff-tree[1] arguments to be used\n \tfor linkgit:git-whatchanged[1].\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 353f9c7..381e3c8 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -566,7 +566,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \t\t\t\tshowed_ident++ ? \"\" : \"#\\n\",\n \t\t\t\tauthor_ident);\n \n-\t\tif (!user_explicit)\n+\t\tif (!user_explicit && user_warnautomatic)\n \t\t\tfprintf(fp,\n \t\t\t\t\"%s\"\n \t\t\t\t\"# Committer: %s\\n\",\ndiff --git a/cache.h b/cache.h\nindex e8b26cf..5d0dd23 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -719,6 +719,7 @@ extern int config_error_nonbool(const char *);\n extern char git_default_email[MAX_GITNAME];\n extern char git_default_name[MAX_GITNAME];\n extern int user_explicit;\n+extern int user_warnautomatic;\n \n extern const char *git_commit_encoding;\n extern const char *git_log_output_encoding;\ndiff --git a/config.c b/config.c\nindex e49804a..1588053 100644\n--- a/config.c\n+++ b/config.c\n@@ -457,6 +457,11 @@ int git_default_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"user.warnautomatic\")) {\n+\t\tuser_warnautomatic = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n+\n \tif (!strcmp(var, \"i18n.commitencoding\"))\n \t\treturn git_config_string(&git_commit_encoding, var, value);\n \ndiff --git a/environment.c b/environment.c\nindex b941971..6b6ede6 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -12,6 +12,7 @@\n char git_default_email[MAX_GITNAME];\n char git_default_name[MAX_GITNAME];\n int user_explicit = 0;\n+int user_warnautomatic = 1;\n int trust_executable_bit = 1;\n int quote_path_fully = 1;\n int has_symlinks = 1;\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex 018060c..a63f9c4 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -166,14 +166,25 @@ test_expect_success 'author different from committer' '\n \ttest_cmp expect actual\n '\n \n+unset GIT_COMMITTER_EMAIL\n+unset GIT_COMMITTER_NAME\n+\n+test_expect_success 'committer is automatic but user.warnautomatic=no' '\n+\n+\tgit config user.warnautomatic no\n+\techo >>negative &&\n+\tgit commit -e -m \"sample\"\n+\thead -n 7 .git/COMMIT_EDITMSG >actual &&\n+\ttest_cmp expect actual\n+'\n+\n sed -i '$d' expect\n echo \"# Committer:\n #\" >> expect\n-unset GIT_COMMITTER_EMAIL\n-unset GIT_COMMITTER_NAME\n \n test_expect_success 'committer is automatic' '\n \n+\tgit config --unset user.warnautomatic\n \techo >>negative &&\n \tgit commit -e -m \"sample\"\n \thead -n 8 .git/COMMIT_EDITMSG |\t\\\n-- \n1.5.5.1.224.gadb29\n"},{"id":"76025","messageId":"8aa486160805040912h38d81750p83353d21e8c2da6d@mail.gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-2-git-send-email-sbejar@gmail.com","subject":"Re: [PATCHv4 1/4] Preparation to call determine_author_info from prepare_to_commit","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:12:19Z","receivedAt":"2008-05-04T16:12:19Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Sun, May 4, 2008 at 6:04 PM, Santi Béjar <sbejar@gmail.com> wrote:\n> From: Santi Béjar <sbjear@gmail.com>\n\nGggrrr!! I thought I had fixed this. Please remove this line.\n\nSanti\n\n>\n>  Reorder functions definitions such that determine_author_info is\n>  defined before prepare_to_commit. No code changes.\n>\n>  Signed-off-by: Santi Béjar <sbejar@gmail.com>\n>  ---\n>   builtin-commit.c |   78 +++++++++++++++++++++++++++---------------------------\n>   1 files changed, 39 insertions(+), 39 deletions(-)\n>\n>  diff --git a/builtin-commit.c b/builtin-commit.c\n>  index 256181a..a37d8c3 100644\n>  --- a/builtin-commit.c\n>  +++ b/builtin-commit.c\n>  @@ -395,6 +395,45 @@ static int is_a_merge(const unsigned char *sha1)\n>\n>   static const char sign_off_header[] = \"Signed-off-by: \";\n>\n>  +static void determine_author_info(struct strbuf *sb)\n>  +{\n>  +       char *name, *email, *date;\n>  +\n>  +       name = getenv(\"GIT_AUTHOR_NAME\");\n>  +       email = getenv(\"GIT_AUTHOR_EMAIL\");\n>  +       date = getenv(\"GIT_AUTHOR_DATE\");\n>  +\n>  +       if (use_message) {\n>  +               const char *a, *lb, *rb, *eol;\n>  +\n>  +               a = strstr(use_message_buffer, \"\\nauthor \");\n>  +               if (!a)\n>  +                       die(\"invalid commit: %s\", use_message);\n>  +\n>  +               lb = strstr(a + 8, \" <\");\n>  +               rb = strstr(a + 8, \"> \");\n>  +               eol = strchr(a + 8, '\\n');\n>  +               if (!lb || !rb || !eol)\n>  +                       die(\"invalid commit: %s\", use_message);\n>  +\n>  +               name = xstrndup(a + 8, lb - (a + 8));\n>  +               email = xstrndup(lb + 2, rb - (lb + 2));\n>  +               date = xstrndup(rb + 2, eol - (rb + 2));\n>  +       }\n>  +\n>  +       if (force_author) {\n>  +               const char *lb = strstr(force_author, \" <\");\n>  +               const char *rb = strchr(force_author, '>');\n>  +\n>  +               if (!lb || !rb)\n>  +                       die(\"malformed --author parameter\");\n>  +               name = xstrndup(force_author, lb - force_author);\n>  +               email = xstrndup(lb + 2, rb - (lb + 2));\n>  +       }\n>  +\n>  +       strbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n>  +}\n>  +\n>   static int prepare_to_commit(const char *index_file, const char *prefix)\n>   {\n>         struct stat statbuf;\n>  @@ -622,45 +661,6 @@ static int message_is_empty(struct strbuf *sb, int start)\n>         return 1;\n>   }\n>\n>  -static void determine_author_info(struct strbuf *sb)\n>  -{\n>  -       char *name, *email, *date;\n>  -\n>  -       name = getenv(\"GIT_AUTHOR_NAME\");\n>  -       email = getenv(\"GIT_AUTHOR_EMAIL\");\n>  -       date = getenv(\"GIT_AUTHOR_DATE\");\n>  -\n>  -       if (use_message) {\n>  -               const char *a, *lb, *rb, *eol;\n>  -\n>  -               a = strstr(use_message_buffer, \"\\nauthor \");\n>  -               if (!a)\n>  -                       die(\"invalid commit: %s\", use_message);\n>  -\n>  -               lb = strstr(a + 8, \" <\");\n>  -               rb = strstr(a + 8, \"> \");\n>  -               eol = strchr(a + 8, '\\n');\n>  -               if (!lb || !rb || !eol)\n>  -                       die(\"invalid commit: %s\", use_message);\n>  -\n>  -               name = xstrndup(a + 8, lb - (a + 8));\n>  -               email = xstrndup(lb + 2, rb - (lb + 2));\n>  -               date = xstrndup(rb + 2, eol - (rb + 2));\n>  -       }\n>  -\n>  -       if (force_author) {\n>  -               const char *lb = strstr(force_author, \" <\");\n>  -               const char *rb = strchr(force_author, '>');\n>  -\n>  -               if (!lb || !rb)\n>  -                       die(\"malformed --author parameter\");\n>  -               name = xstrndup(force_author, lb - force_author);\n>  -               email = xstrndup(lb + 2, rb - (lb + 2));\n>  -       }\n>  -\n>  -       strbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n>  -}\n>  -\n>   static int parse_and_validate_options(int argc, const char *argv[],\n>                                       const char * const usage[])\n>   {\n>  --\n>  1.5.5.1.224.gadb29\n>\n>\n"},{"id":"76026","messageId":"8aa486160805040925i6a10d704oa31651cc2b244322@mail.gmail.com","threadId":"13373","inReplyTo":"1209917092-12146-1-git-send-email-sbejar@gmail.com","subject":"Re: [PATCHv4 0/4] Show author and/or committer in some cases","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-04T16:25:40Z","receivedAt":"2008-05-04T16:25:40Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Sun, May 4, 2008 at 6:04 PM, Santi Béjar <sbejar@gmail.com> wrote:\n> Hi *,\n>\n>   This patch series tries to make more evident the author and committer ident\n>  in case the user might be using an unintended author/committer identity.\n>\n\nOops, I send it without saving the buffer.\n\nChanges since last round (v3?):\n\n\t* removed an unused function\n \t* Add comment why git_committer_info is called discarding the value\n\t* Minor changes to the tests\n\n>  Santi\n>\n>  Santi Béjar (4):\n>   Preparation to call determine_author_info from prepare_to_commit\n>   commit: Show author if different from committer\n>   commit: Show committer if automatic\n>   user.warnautomatic: add config to control if the committer ident is\n>     shown\n>\n>   Documentation/config.txt |    4 ++\n>   builtin-commit.c         |  112 +++++++++++++++++++++++++++++----------------\n>   cache.h                  |    2 +\n>   config.c                 |    9 ++++\n>   environment.c            |    2 +\n>   ident.c                  |    3 +\n>   t/t7502-commit.sh        |   38 ++++++++++++++++\n>   7 files changed, 130 insertions(+), 40 deletions(-)\n>\n>\n"},{"id":"76230","messageId":"7vej8fgg6b.fsf@gitster.siamese.dyndns.org","threadId":"13373","inReplyTo":"1209917092-12146-3-git-send-email-sbejar@gmail.com","subject":"Re: [PATCHv4 2/4] commit: Show author if different from committer","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-06T23:34:52Z","receivedAt":"2008-05-06T23:34:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi Béjar <sbejar@gmail.com> writes:\n\n> That would help reassure anybody while committing other's changes.\n>\n> Signed-off-by: Santi Béjar <sbejar@gmail.com>\n> ---\n>  builtin-commit.c  |   25 ++++++++++++++++++++++---\n>  t/t7502-commit.sh |   12 ++++++++++++\n>  2 files changed, 34 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index a37d8c3..d03b6b2 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -47,6 +47,7 @@ static enum {\n>  \n>  static char *logfile, *force_author, *template_file;\n>  static char *edit_message, *use_message;\n> +static char *author_name, *author_email, *author_date;\n>  static int all, edit_flag, also, interactive, only, amend, signoff;\n>  static int quiet, verbose, untracked_files, no_verify, allow_empty;\n>  /*\n> @@ -395,7 +396,7 @@ static int is_a_merge(const unsigned char *sha1)\n>  \n>  static const char sign_off_header[] = \"Signed-off-by: \";\n>  \n> -static void determine_author_info(struct strbuf *sb)\n> +static void determine_author_info(void)\n>  {\n>  \tchar *name, *email, *date;\n>  \n\nThe parameter list here should be \"(void)\" like the above (I've already\ntouched up).\n\n> @@ -545,6 +552,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n>  \t\tif (only_include_assumed)\n>  \t\t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n>  \n> +\t\tauthor_ident = xstrdup(fmt_name(author_name, author_email));\n> +\t\tcommitter_ident =\n> +\t\t\txstrdup(fmt_name(getenv(\"GIT_COMMITTER_NAME\"),\n> +\t\t\t\t\t getenv(\"GIT_COMMITTER_EMAIL\")));\n\nThe lifetime of these two variables are inside \"if (use_editor)\" so it\nwould be better to move the decl inside it.  Then it would become more\nobvious that these two leaks and are safe to free at the end of the\nscope.\n"},{"id":"76300","messageId":"7v8wymdred.fsf@gitster.siamese.dyndns.org","threadId":"13373","inReplyTo":"1209917092-12146-5-git-send-email-sbejar@gmail.com","subject":"Re: [PATCHv4 4/4] user.warnautomatic: add config to control if the committer ident is shown","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-07T16:12:58Z","receivedAt":"2008-05-07T16:12:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi Béjar <sbejar@gmail.com> writes:\n\n> Signed-off-by: Santi Béjar <sbejar@gmail.com>\n\nBy setting this new variable the user can squelch undesired noise the\nprevious change introduces, but the user can just set user.name and\nuser.email to desired values to squelch it anyway.\n\nSo either this new variable is superfluous, or the previous change is too\nsusceptible to produce false positives that need squelching with such a\nvariable, or both.  In any case, not a very good sign.\n"},{"id":"76306","messageId":"8aa486160805070932w44edf4b0j3b712ec22c10fe7d@mail.gmail.com","threadId":"13373","inReplyTo":"7v8wymdred.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCHv4 4/4] user.warnautomatic: add config to control if the committer ident is shown","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-07T16:32:24Z","receivedAt":"2008-05-07T16:32:24Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Wed, May 7, 2008 at 6:12 PM, Junio C Hamano <junio@pobox.com> wrote:\n> Santi Béjar <sbejar@gmail.com> writes:\n>\n>  > Signed-off-by: Santi Béjar <sbejar@gmail.com>\n>\n>  By setting this new variable the user can squelch undesired noise the\n>  previous change introduces, but the user can just set user.name and\n>  user.email to desired values to squelch it anyway.\n\nOr the user prefers the automatic ident.\n\n>\n>  So either this new variable is superfluous, or the previous change is too\n>  susceptible to produce false positives that need squelching with such a\n>  variable, or both.  In any case, not a very good sign.\n\nFor me it is superfluous, as I prefer to see what is the committer\nident when it is generated.\nI even said I prefer just showing the automatic ident. I sent it in\ncase it was decided it was worth.\n\nSanti\n"}]}