{"thread":{"id":"50068","subject":"[PATCH 0/1] add author and committer configuration settings","startedAt":"2018-12-19T18:41:01Z","lastAt":"2019-01-02T22:57:49Z","messageCount":6,"participants":["William Hubbs","John Passaro","Jonathan Nieder","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"365589","messageId":"20181219183939.16358-1-williamh@gentoo.org","threadId":"50068","inReplyTo":null,"subject":"[PATCH 0/1] add author and committer configuration settings","fromName":"William Hubbs","fromEmail":"williamh@gentoo.org","sentAt":"2018-12-19T18:39:38Z","receivedAt":"2018-12-19T18:41:01Z","isPatch":true,"sender":{"key":"williamh@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/64355?v=4"},"body":"Hi all,\n\nthis is my first patch for git, so please be gentle. ;-)\n\nI am in a situation where I need to use different authorship information\nfor some repositories I commit to.\n\nGit already supports setting different authorship and committer\ninformation with environment variables, but this setting is global so if\nyou want to change it per repository you need to use a separate tool.\n\nThis patch adds support to git config for author.email, author.name,\ncommitter.email and committer.name  settings so this information\ncan be set per repository. It applies to current master.\n\nThanks much for your reviews, and I would like to publically thank dscho\nfrom #git-devel for assisting me in preparing this patch.\n\nAlso, since I use a screen reader, it would be very helpful if you put\nyour comments in your replies as close to the affected code as possible,\npreferably directly below it.\n\nWilliam Hubbs (1):\n  Add author and committer configuration settings\n\n Documentation/config/user.txt | 20 +++++++++++\n builtin/commit.c              |  2 +-\n cache.h                       |  5 ++-\n config.c                      |  6 ++++\n ident.c                       | 68 ++++++++++++++++++++++++++++++++---\n log-tree.c                    |  3 +-\n sequencer.c                   |  3 +-\n 7 files changed, 97 insertions(+), 10 deletions(-)\n\n-- \n2.19.2\n\n"},{"id":"365590","messageId":"20181219183939.16358-2-williamh@gentoo.org","threadId":"50068","inReplyTo":"20181219183939.16358-1-williamh@gentoo.org","subject":"[PATCH 1/1] Add author and committer configuration settings","fromName":"William Hubbs","fromEmail":"williamh@gentoo.org","sentAt":"2018-12-19T18:39:39Z","receivedAt":"2018-12-19T18:41:05Z","isPatch":true,"sender":{"key":"williamh@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/64355?v=4"},"body":"    The author.email, author.name, committer.email and committer.name\n    settings are analogous to the GIT_AUTHOR_* and GIT_COMMITTER_*\n    environment variables, but for the git config system. This allows them\n    to be set separately for each repository.\n\nSigned-off-by: William Hubbs <williamh@gentoo.org>\n---\n Documentation/config/user.txt | 20 +++++++++++\n builtin/commit.c              |  2 +-\n cache.h                       |  5 ++-\n config.c                      |  6 ++++\n ident.c                       | 68 ++++++++++++++++++++++++++++++++---\n log-tree.c                    |  3 +-\n sequencer.c                   |  3 +-\n 7 files changed, 97 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/config/user.txt b/Documentation/config/user.txt\nindex b5b2ba1199..6ba7002252 100644\n--- a/Documentation/config/user.txt\n+++ b/Documentation/config/user.txt\n@@ -1,3 +1,23 @@\n+author.email::\n+Your email address to be recorded on the author line of any newly\n+created commits.\n+If this is not set, we use user.email.\n+\n+author.name::\n+Your full name to be recorded on the author line of any newly\n+created commits.\n+If this is not set, we use user.name.\n+\n+committer.email::\n+Your email address to be recorded on the committer line of any newly\n+created commits.\n+If this is not set, we use user.email.\n+\n+committer.name::\n+Your full name to be recorded on the committer line of any newly\n+created commits.\n+If this is not set, we use user.name.\n+\n user.email::\n \tYour email address to be recorded in any newly created commits.\n \tCan be overridden by the `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`, and\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex c021b119bb..49a97adeb8 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -607,7 +607,7 @@ static void determine_author_info(struct strbuf *author_ident)\n \t\tset_ident_var(&date, strbuf_detach(&date_buf, NULL));\n \t}\n \n-\tstrbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));\n+\tstrbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT|IDENT_AUTHOR));\n \tassert_split_ident(&author, author_ident);\n \texport_one(\"GIT_AUTHOR_NAME\", author.name_begin, author.name_end, 0);\n \texport_one(\"GIT_AUTHOR_EMAIL\", author.mail_begin, author.mail_end, 0);\ndiff --git a/cache.h b/cache.h\nindex ca36b44ee0..0ee87f22a9 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1479,10 +1479,13 @@ int date_overflows(timestamp_t date);\n #define IDENT_STRICT\t       1\n #define IDENT_NO_DATE\t       2\n #define IDENT_NO_NAME\t       4\n+#define IDENT_AUTHOR          8\n+#define IDENT_COMMITTER       16\n+\n extern const char *git_author_info(int);\n extern const char *git_committer_info(int);\n extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);\n-extern const char *fmt_name(const char *name, const char *email);\n+extern const char *fmt_committer_name(void);\n extern const char *ident_default_name(void);\n extern const char *ident_default_email(void);\n extern const char *git_editor(void);\ndiff --git a/config.c b/config.c\nindex ff521eb27a..4bd5920dea 100644\n--- a/config.c\n+++ b/config.c\n@@ -1484,6 +1484,12 @@ int git_default_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (starts_with(var, \"author.\"))\n+\t\treturn git_ident_config(var, value, cb);\n+\n+\tif (starts_with(var, \"committer.\"))\n+\t\treturn git_ident_config(var, value, cb);\n+\n \t/* Add other config variables here and to Documentation/config.txt. */\n \treturn 0;\n }\ndiff --git a/ident.c b/ident.c\nindex 33bcf40644..3da96ebbef 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -11,6 +11,10 @@\n static struct strbuf git_default_name = STRBUF_INIT;\n static struct strbuf git_default_email = STRBUF_INIT;\n static struct strbuf git_default_date = STRBUF_INIT;\n+static struct strbuf git_author_name = STRBUF_INIT;\n+static struct strbuf git_author_email = STRBUF_INIT;\n+static struct strbuf git_committer_name = STRBUF_INIT;\n+static struct strbuf git_committer_email = STRBUF_INIT;\n static int default_email_is_bogus;\n static int default_name_is_bogus;\n \n@@ -361,7 +365,15 @@ const char *fmt_ident(const char *name, const char *email,\n \tint strict = (flag & IDENT_STRICT);\n \tint want_date = !(flag & IDENT_NO_DATE);\n \tint want_name = !(flag & IDENT_NO_NAME);\n+\tint want_author = (flag & IDENT_AUTHOR);\n+\tint want_committer = (flag & IDENT_COMMITTER);\n \n+\tif (!email) {\n+\t\tif (want_author && git_author_email.len)\n+\t\t\temail = git_author_email.buf;\n+\t\telse if (want_committer && git_committer_email.len)\n+\t\t\temail = git_committer_email.buf;\n+\t}\n \tif (!email) {\n \t\tif (strict && ident_use_config_only\n \t\t    && !(ident_config_given & IDENT_MAIL_GIVEN)) {\n@@ -377,6 +389,12 @@ const char *fmt_ident(const char *name, const char *email,\n \n \tif (want_name) {\n \t\tint using_default = 0;\n+\t\tif (!name) {\n+\t\t\tif (want_author && git_author_name.len)\n+\t\t\t\tname = git_author_name.buf;\n+\t\t\telse if (want_committer && git_committer_name.len)\n+\t\t\t\tname = git_committer_name.buf;\n+\t\t}\n \t\tif (!name) {\n \t\t\tif (strict && ident_use_config_only\n \t\t\t    && !(ident_config_given & IDENT_NAME_GIVEN)) {\n@@ -425,9 +443,11 @@ const char *fmt_ident(const char *name, const char *email,\n \treturn ident.buf;\n }\n \n-const char *fmt_name(const char *name, const char *email)\n+const char *fmt_committer_name(void)\n {\n-\treturn fmt_ident(name, email, NULL, IDENT_STRICT | IDENT_NO_DATE);\n+\tchar *name = getenv(\"GIT_COMMITTER_NAME\");\n+\tchar *email = getenv(\"GIT_COMMITTER_EMAIL\");\n+\treturn fmt_ident(name, email, NULL, IDENT_STRICT | IDENT_NO_DATE|IDENT_COMMITTER);\n }\n \n const char *git_author_info(int flag)\n@@ -439,7 +459,7 @@ const char *git_author_info(int flag)\n \treturn fmt_ident(getenv(\"GIT_AUTHOR_NAME\"),\n \t\t\t getenv(\"GIT_AUTHOR_EMAIL\"),\n \t\t\t getenv(\"GIT_AUTHOR_DATE\"),\n-\t\t\t flag);\n+\t\t\t flag|IDENT_AUTHOR);\n }\n \n const char *git_committer_info(int flag)\n@@ -451,7 +471,7 @@ const char *git_committer_info(int flag)\n \treturn fmt_ident(getenv(\"GIT_COMMITTER_NAME\"),\n \t\t\t getenv(\"GIT_COMMITTER_EMAIL\"),\n \t\t\t getenv(\"GIT_COMMITTER_DATE\"),\n-\t\t\t flag);\n+\t\t\t flag|IDENT_COMMITTER);\n }\n \n static int ident_is_sufficient(int user_ident_explicitly_given)\n@@ -480,6 +500,46 @@ int git_ident_config(const char *var, const char *value, void *data)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"author.name\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tstrbuf_reset(&git_author_name);\n+\t\tstrbuf_addstr(&git_author_name, value);\n+\t\tauthor_ident_explicitly_given |= IDENT_NAME_GIVEN;\n+\t\tident_config_given |= IDENT_NAME_GIVEN;\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"author.email\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tstrbuf_reset(&git_author_email);\n+\t\tstrbuf_addstr(&git_author_email, value);\n+\t\tauthor_ident_explicitly_given |= IDENT_MAIL_GIVEN;\n+\t\tident_config_given |= IDENT_MAIL_GIVEN;\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"committer.name\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tstrbuf_reset(&git_committer_name);\n+\t\tstrbuf_addstr(&git_committer_name, value);\n+\t\tcommitter_ident_explicitly_given |= IDENT_NAME_GIVEN;\n+\t\tident_config_given |= IDENT_NAME_GIVEN;\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"committer.email\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tstrbuf_reset(&git_committer_email);\n+\t\tstrbuf_addstr(&git_committer_email, value);\n+\t\tcommitter_ident_explicitly_given |= IDENT_MAIL_GIVEN;\n+\t\tident_config_given |= IDENT_MAIL_GIVEN;\n+\t\treturn 0;\n+\t}\n+\n \tif (!strcmp(var, \"user.name\")) {\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\ndiff --git a/log-tree.c b/log-tree.c\nindex 10680c139e..6760a2e9c4 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -687,8 +687,7 @@ void show_log(struct rev_info *opt)\n \t */\n \tif (ctx.need_8bit_cte >= 0 && opt->add_signoff)\n \t\tctx.need_8bit_cte =\n-\t\t\thas_non_ascii(fmt_name(getenv(\"GIT_COMMITTER_NAME\"),\n-\t\t\t\t\t       getenv(\"GIT_COMMITTER_EMAIL\")));\n+\t\t\thas_non_ascii(fmt_committer_name());\n \tctx.date_mode = opt->date_mode;\n \tctx.date_mode_explicit = opt->date_mode_explicit;\n \tctx.abbrev = opt->diffopt.abbrev;\ndiff --git a/sequencer.c b/sequencer.c\nindex e1a4dd15f1..f357defda5 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -4036,8 +4036,7 @@ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag)\n \tint has_footer;\n \n \tstrbuf_addstr(&sob, sign_off_header);\n-\tstrbuf_addstr(&sob, fmt_name(getenv(\"GIT_COMMITTER_NAME\"),\n-\t\t\t\tgetenv(\"GIT_COMMITTER_EMAIL\")));\n+\tstrbuf_addstr(&sob, fmt_committer_name());\n \tstrbuf_addch(&sob, '\\n');\n \n \tif (!ignore_footer)\n-- \n2.19.2\n\n"},{"id":"365593","messageId":"CAJdN7KhyTSSzTrJDPkfTMsJqojo9ReW5VeAikANPZNQSpvQBmw@mail.gmail.com","threadId":"50068","inReplyTo":"20181219183939.16358-2-williamh@gentoo.org","subject":"Re: [PATCH 1/1] Add author and committer configuration settings","fromName":"John Passaro","fromEmail":"john.a.passaro@gmail.com","sentAt":"2018-12-19T20:05:15Z","receivedAt":"2018-12-19T20:05:57Z","isPatch":true,"sender":{"key":"john.a.passaro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6754005?v=4"},"body":"On Wed, Dec 19, 2018 at 2:19 PM William Hubbs <williamh@gentoo.org> wrote:\n>\n>     The author.email, author.name, committer.email and committer.name\n>     settings are analogous to the GIT_AUTHOR_* and GIT_COMMITTER_*\n>     environment variables, but for the git config system. This allows them\n>     to be set separately for each repository.\n>\n\nGreat! I didn't realize this wasn't already supported...\n\nHowever your patch does seem to be missing tests.\nt/t7517-per-repo-email.sh would appear to be a logical place to add\nthem.\n\n> Signed-off-by: William Hubbs <williamh@gentoo.org>\n> ---\n>  Documentation/config/user.txt | 20 +++++++++++\n>  builtin/commit.c              |  2 +-\n>  cache.h                       |  5 ++-\n>  config.c                      |  6 ++++\n>  ident.c                       | 68 ++++++++++++++++++++++++++++++++---\n>  log-tree.c                    |  3 +-\n>  sequencer.c                   |  3 +-\n>  7 files changed, 97 insertions(+), 10 deletions(-)\n>\n> diff --git a/Documentation/config/user.txt b/Documentation/config/user.txt\n> index b5b2ba1199..6ba7002252 100644\n> --- a/Documentation/config/user.txt\n> +++ b/Documentation/config/user.txt\n> @@ -1,3 +1,23 @@\n> +author.email::\n> +Your email address to be recorded on the author line of any newly\n> +created commits.\n> +If this is not set, we use user.email.\n> +\n> +author.name::\n> +Your full name to be recorded on the author line of any newly\n> +created commits.\n> +If this is not set, we use user.name.\n> +\n> +committer.email::\n> +Your email address to be recorded on the committer line of any newly\n> +created commits.\n> +If this is not set, we use user.email.\n> +\n> +committer.name::\n> +Your full name to be recorded on the committer line of any newly\n> +created commits.\n> +If this is not set, we use user.name.\n> +\n>  user.email::\n>         Your email address to be recorded in any newly created commits.\n>         Can be overridden by the `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`, and\n\nI think it would be wise to mention the new config items under\nuser.email and user.name as well.\n"},{"id":"365598","messageId":"20181219214651.GB228469@google.com","threadId":"50068","inReplyTo":"20181219183939.16358-1-williamh@gentoo.org","subject":"Re: [PATCH 0/1] add author and committer configuration settings","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-12-19T21:46:51Z","receivedAt":"2018-12-19T21:46:56Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nWilliam Hubbs wrote:\n\n> this is my first patch for git, so please be gentle. ;-)\n\nThanks for contributing!\n\n> I am in a situation where I need to use different authorship information\n> for some repositories I commit to.\n>\n> Git already supports setting different authorship and committer\n> information with environment variables, but this setting is global so if\n> you want to change it per repository you need to use a separate tool.\n>\n> This patch adds support to git config for author.email, author.name,\n> committer.email and committer.name  settings so this information\n> can be set per repository. It applies to current master.\n\nThe above information (except for \"It applies to current master\") is\nvery useful to have when looking back at the change in history.  When\nsending the next version of this patch in response to others'\ncomments, can you replace the commit message with something like it?\n\nIn other words, it is very useful for the commit message to include\nthis kind of information about the \"why\" behind a change, beyond the\n\"what\" that the patch itself already provides.\n\n> Thanks much for your reviews, and I would like to publically thank dscho\n> from #git-devel for assisting me in preparing this patch.\n>\n> Also, since I use a screen reader, it would be very helpful if you put\n> your comments in your replies as close to the affected code as possible,\n> preferably directly below it.\n\nFortunately, this is already common practice here, but the reminder is\nvery welcome.\n\nBy the way, if you have other feedback about Git accessibility through\na screen reader (both the project and the tool), I would be very\ninterested to hear.  Presumably in a new thread. :)\n\nThanks and hope that helps,\nJonathan\n"},{"id":"365728","messageId":"nycvar.QRO.7.76.6.1812211310040.41@tvgsbejvaqbjf.bet","threadId":"50068","inReplyTo":"20181219183939.16358-2-williamh@gentoo.org","subject":"Re: [PATCH 1/1] Add author and committer configuration settings","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-21T12:15:40Z","receivedAt":"2018-12-21T12:16:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi William,\n\nthank you for putting this together.\n\nOn Wed, 19 Dec 2018, William Hubbs wrote:\n\n> -extern const char *fmt_name(const char *name, const char *email);\n> +extern const char *fmt_committer_name(void);\n\nIf it would not be too much trouble for you, could I ask you to split this\nchange out into a separate commit (which would be the first of now two\npatches)? It could have a commit message like this:\n\n\tident: rename fmt_name() to fmt_committer_name()\n\n\tEver since 4c28e4ada03f (commit: die before asking to edit the log\n\tmessage, 2010-12-20), all remaining callers of that function want\n\tto format the committer name. To simplify the code, therefore, we\n\trename the function and move the getenv() call into it.\n\nCiao,\nDscho\n"},{"id":"366056","messageId":"xmqq1s5uk6qh.fsf@gitster-ct.c.googlers.com","threadId":"50068","inReplyTo":"20181219183939.16358-2-williamh@gentoo.org","subject":"Re: [PATCH 1/1] Add author and committer configuration settings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-02T22:57:42Z","receivedAt":"2019-01-02T22:57:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"William Hubbs <williamh@gentoo.org> writes:\n\n> Subject: Re: [PATCH 1/1]     Add author and committer configuration settings\n\nPerhaps something like this\n\n\tSubject: config: allow giving separate author and committer idents\n\nwould fit better in \"git shortlog --no-merges\" output.\n\n>     The author.email, author.name, committer.email and committer.name\n>     settings are analogous to the GIT_AUTHOR_* and GIT_COMMITTER_*\n>     environment variables, but for the git config system. This allows them\n>     to be set separately for each repository.\n\nDon't indent the whole proposed log message.\n\n> diff --git a/Documentation/config/user.txt b/Documentation/config/user.txt\n> index b5b2ba1199..6ba7002252 100644\n> --- a/Documentation/config/user.txt\n> +++ b/Documentation/config/user.txt\n> @@ -1,3 +1,23 @@\n> +author.email::\n> +Your email address to be recorded on the author line of any newly\n> +created commits.\n> +If this is not set, we use user.email.\n\n\"author line\" is a bit too technical and appropriate only to those\nwho are familiar with \"git cat-file commit\" output.  How about\nphrasing it a bit differently, like\n\n\tauthor.email::\n\t\tThe email-address used for the author of newly\n\t\tcreated commits.  Defaults to the value of the\n\t\t`GIT_AUTHOR_EMAIL` environment variable, or if it is\n\t\tnot set, the `user.email` configuration variable.\n\nLikewise for the other three variables.\n\n>  user.email::\n>  \tYour email address to be recorded in any newly created commits.\n>  \tCan be overridden by the `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`, and\n\nAs you can see, the enumeration list in this file is formatted by\nindenting the definition body.  \n\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index c021b119bb..49a97adeb8 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -607,7 +607,7 @@ static void determine_author_info(struct strbuf *author_ident)\n>  \t\tset_ident_var(&date, strbuf_detach(&date_buf, NULL));\n>  \t}\n>  \n> -\tstrbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));\n> +\tstrbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT|IDENT_AUTHOR));\n\nThat's now a bit overly long line.\n\n>  \tassert_split_ident(&author, author_ident);\n>  \texport_one(\"GIT_AUTHOR_NAME\", author.name_begin, author.name_end, 0);\n>  \texport_one(\"GIT_AUTHOR_EMAIL\", author.mail_begin, author.mail_end, 0);\n> diff --git a/cache.h b/cache.h\n> index ca36b44ee0..0ee87f22a9 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1479,10 +1479,13 @@ int date_overflows(timestamp_t date);\n>  #define IDENT_STRICT\t       1\n>  #define IDENT_NO_DATE\t       2\n>  #define IDENT_NO_NAME\t       4\n> +#define IDENT_AUTHOR          8\n> +#define IDENT_COMMITTER       16\n\n>  extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);\n\nIt is wrong to pass \"do we want the author, or the committer, name?\"\ninformation in the same flag parameter to fmt_ident(), and it is\nwrong to introduce IDENT_AUTHOR/COMMITTER bits as if they belong to\nthe existing four.  For one thing, unlike these other bits, these\ntwo are not independent bits.  It would be an error for a caller to\npass neither bits, or both bits at the same time.\n\nOne way to do it better may be to pass it as another parameter, e.g.\n\n\tenum want_ident {\n\t\tWANT_AUTHOR_IDENT,\n\t\tWANT_COMMITTER_IDENT\n\t};\n\tconst char *fmt_ident(const char *name, const char *email,\n\t\t\t\tenum want_ident whose_ident,\n\t\t\t\tconst char *date_str, int flags);\n\nIn the remainder of the review, I'd give update suggestions based on\nthis function signature.\n\n> diff --git a/ident.c b/ident.c\n> index 33bcf40644..3da96ebbef 100644\n> --- a/ident.c\n> +++ b/ident.c\n> @@ -11,6 +11,10 @@\n>  static struct strbuf git_default_name = STRBUF_INIT;\n>  static struct strbuf git_default_email = STRBUF_INIT;\n>  static struct strbuf git_default_date = STRBUF_INIT;\n> +static struct strbuf git_author_name = STRBUF_INIT;\n> +static struct strbuf git_author_email = STRBUF_INIT;\n> +static struct strbuf git_committer_name = STRBUF_INIT;\n> +static struct strbuf git_committer_email = STRBUF_INIT;\n>  static int default_email_is_bogus;\n>  static int default_name_is_bogus;\n>  \n> @@ -361,7 +365,15 @@ const char *fmt_ident(const char *name, const char *email,\n>  \tint strict = (flag & IDENT_STRICT);\n>  \tint want_date = !(flag & IDENT_NO_DATE);\n>  \tint want_name = !(flag & IDENT_NO_NAME);\n> +\tint want_author = (flag & IDENT_AUTHOR);\n> +\tint want_committer = (flag & IDENT_COMMITTER);\n>  \n> +\tif (!email) {\n> +\t\tif (want_author && git_author_email.len)\n> +\t\t\temail = git_author_email.buf;\n> +\t\telse if (want_committer && git_committer_email.len)\n> +\t\t\temail = git_committer_email.buf;\n> +\t}\n>  \tif (!email) {\n>  \t\tif (strict && ident_use_config_only\n>  \t\t    && !(ident_config_given & IDENT_MAIL_GIVEN)) {\n> @@ -377,6 +389,12 @@ const char *fmt_ident(const char *name, const char *email,\n>  \n>  \tif (want_name) {\n>  \t\tint using_default = 0;\n> +\t\tif (!name) {\n> +\t\t\tif (want_author && git_author_name.len)\n> +\t\t\t\tname = git_author_name.buf;\n> +\t\t\telse if (want_committer && git_committer_name.len)\n> +\t\t\t\tname = git_committer_name.buf;\n> +\t\t}\n>  \t\tif (!name) {\n>  \t\t\tif (strict && ident_use_config_only\n>  \t\t\t    && !(ident_config_given & IDENT_NAME_GIVEN)) {\n\nThe reviewer's interest here is to see how \"author.name trumps\nuser.name\" precedence is implemented; by mucking with \"name\" before\nthe code that deals with the ident_default_name(), which yields\ngit_default_name taken from user.name, the code gives precedence to\nthese newly introduced variables.\n\nWhich makes sense.\n\n> @@ -425,9 +443,11 @@ const char *fmt_ident(const char *name, const char *email,\n>  \treturn ident.buf;\n>  }\n>  \n> -const char *fmt_name(const char *name, const char *email)\n> +const char *fmt_committer_name(void)\n>  {\n> -\treturn fmt_ident(name, email, NULL, IDENT_STRICT | IDENT_NO_DATE);\n> +\tchar *name = getenv(\"GIT_COMMITTER_NAME\");\n> +\tchar *email = getenv(\"GIT_COMMITTER_EMAIL\");\n> +\treturn fmt_ident(name, email, NULL, IDENT_STRICT | IDENT_NO_DATE|IDENT_COMMITTER);\n>  }\n\nOK, we are lucky that no existing caller use fmt_name() with author\ninformation, I guess?  The resulting codebase does invite a question\n\"why don't we have fmt_author_name() at all?\", which is somewhat\ndisturbing.\n\nAs we are going to change this function *and* all of its callers\nanyway, perhaps we can generalize it with minimum effort, like so:\n\n\tconst char *fmt_name(enum want_ident whose_ident)\n\t{\n\t\tswitch (whose_ident) {\n\t\tcase WANT_AUTHOR_IDENT:\n\t\t\tname = getenv(\"GIT_AUTHOR_NAME\");\n\t\t\temail = getenv(\"GIT_COMMITTER_NAME\");\n\t\t\tbreak;\n\t\tcase WANT_COMMITTER_IDENT:\n\t\t\t...\n\t\t}\n\t\treturn fmt_ident(name, email, whose_ident,\n\t\t\t\t  NULL, IDENT_STRICT | IDENT_NO_DATE);\n\t}\n\nThanks.\n"}]}