William Hubbs <williamh@xxxxxxxxxx> writes: > diff --git a/cache.h b/cache.h > index 009e8b3b15..375be1f68b 100644 > --- a/cache.h > +++ b/cache.h > @@ -1494,10 +1494,19 @@ int date_overflows(timestamp_t date); > #define IDENT_STRICT 1 > #define IDENT_NO_DATE 2 > #define IDENT_NO_NAME 4 > + > +enum want_ident { > + WANT_BLANK_IDENT, > + WANT_AUTHOR_IDENT, > + WANT_COMMITTER_IDENT, I do not recall we crossed the bridge to allow trailing comma here at the end of enum definition. > +}; > +extern const char *fmt_ident(const char *name, const char *email, > + enum want_ident whose_ident, > + const char *date_str, int); > +extern const char *fmt_name(enum want_ident); Nice interface. > diff --git a/config.c b/config.c > index ff521eb27a..4bd5920dea 100644 > --- a/config.c > +++ b/config.c > @@ -1484,6 +1484,12 @@ int git_default_config(const char *var, const char *value, void *cb) > return 0; > } > > + if (starts_with(var, "author.")) > + return git_ident_config(var, value, cb); > + > + if (starts_with(var, "committer.")) > + return git_ident_config(var, value, cb); > + I'd rather see this done close to where "user." is already handled, perhaps like - if (starts_with(var, "user.")) + if (starts_with(var, "user.") || + starts_with(var, "author.") || + starts_with(var, "committer.")) return git_ident_config(...); > -int git_ident_config(const char *var, const char *value, void *data) > +static int set_ident(const char *var, const char *value) > { > - if (!strcmp(var, "user.useconfigonly")) { > - ident_use_config_only = git_config_bool(var, value); > + if (!strcmp(var, "author.name")) { > + if (!value) > + return config_error_nonbool(var); > + strbuf_reset(&git_author_name); > + strbuf_addstr(&git_author_name, value); > + author_ident_explicitly_given |= IDENT_NAME_GIVEN; > + ident_config_given |= IDENT_NAME_GIVEN; > + return 0; > + } > + > + if (!strcmp(var, "author.email")) { > + if (!value) > + return config_error_nonbool(var); > + strbuf_reset(&git_author_email); > + strbuf_addstr(&git_author_email, value); > + author_ident_explicitly_given |= IDENT_MAIL_GIVEN; > + ident_config_given |= IDENT_MAIL_GIVEN; > + return 0; > + } > + > + if (!strcmp(var, "committer.name")) { > + if (!value) > + return config_error_nonbool(var); > + strbuf_reset(&git_committer_name); > + strbuf_addstr(&git_committer_name, value); > + committer_ident_explicitly_given |= IDENT_NAME_GIVEN; > + ident_config_given |= IDENT_NAME_GIVEN; > + return 0; > + } > + > + if (!strcmp(var, "committer.email")) { > + if (!value) > + return config_error_nonbool(var); > + strbuf_reset(&git_committer_email); > + strbuf_addstr(&git_committer_email, value); > + committer_ident_explicitly_given |= IDENT_MAIL_GIVEN; > + ident_config_given |= IDENT_MAIL_GIVEN; > return 0; So, when we see "committer.phone", git_default_config() would call git_ident_config() which in turn would call this, and the unknown variable is silently ignored, which is good. > diff --git a/log-tree.c b/log-tree.c > index 3cb14256ec..1e56df62a7 100644 > --- a/log-tree.c > +++ b/log-tree.c > @@ -687,8 +687,7 @@ void show_log(struct rev_info *opt) > */ > if (ctx.need_8bit_cte >= 0 && opt->add_signoff) > ctx.need_8bit_cte = > - has_non_ascii(fmt_name(getenv("GIT_COMMITTER_NAME"), > - getenv("GIT_COMMITTER_EMAIL"))); > + has_non_ascii(fmt_name(WANT_COMMITTER_IDENT)); Very nice.