static int default_email_is_bogus;
static int default_name_is_bogus;
+static int ident_use_config_only;
+
#define IDENT_NAME_GIVEN 01
#define IDENT_MAIL_GIVEN 02
#define IDENT_ALL_GIVEN (IDENT_NAME_GIVEN|IDENT_MAIL_GIVEN)
static int committer_ident_explicitly_given;
static int author_ident_explicitly_given;
+static int ident_config_given;
#ifdef NO_GECOS_IN_PWENT
#define get_gecos(ignored) "&"
strerror(errno));
return -1;
}
- if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) {
+ if (strbuf_getline(&mailnamebuf, mailname) == EOF) {
if (ferror(mailname))
warning("cannot read /etc/mailname: %s",
strerror(errno));
fputs(env_hint, stderr);
die("unable to auto-detect name (got '%s')", name);
}
+ if (strict && ident_use_config_only
+ && !(ident_config_given & IDENT_NAME_GIVEN))
+ die("user.useConfigOnly set but no name given");
}
if (!*name) {
struct passwd *pw;
fputs(env_hint, stderr);
die("unable to auto-detect email address (got '%s')", email);
}
+ if (strict && ident_use_config_only
+ && !(ident_config_given & IDENT_MAIL_GIVEN))
+ die("user.useConfigOnly set but no mail given");
}
strbuf_reset(&ident);
int git_ident_config(const char *var, const char *value, void *data)
{
+ if (!strcmp(var, "user.useconfigonly")) {
+ ident_use_config_only = git_config_bool(var, value);
+ return 0;
+ }
+
if (!strcmp(var, "user.name")) {
if (!value)
return config_error_nonbool(var);
strbuf_addstr(&git_default_name, value);
committer_ident_explicitly_given |= IDENT_NAME_GIVEN;
author_ident_explicitly_given |= IDENT_NAME_GIVEN;
+ ident_config_given |= IDENT_NAME_GIVEN;
return 0;
}
strbuf_addstr(&git_default_email, value);
committer_ident_explicitly_given |= IDENT_MAIL_GIVEN;
author_ident_explicitly_given |= IDENT_MAIL_GIVEN;
+ ident_config_given |= IDENT_MAIL_GIVEN;
return 0;
}