mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
Merge branch 'jc/ident-whose-ident'
Error message update. * jc/ident-whose-ident: ident: say whose identity is missing when giving user.name hint
This commit is contained in:
commit
e9bd00ab2d
48
ident.c
48
ident.c
|
@ -345,18 +345,32 @@ int split_ident_line(struct ident_split *split, const char *line, int len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const char *env_hint =
|
||||
N_("\n"
|
||||
"*** Please tell me who you are.\n"
|
||||
"\n"
|
||||
"Run\n"
|
||||
"\n"
|
||||
" git config --global user.email \"you@example.com\"\n"
|
||||
" git config --global user.name \"Your Name\"\n"
|
||||
"\n"
|
||||
"to set your account\'s default identity.\n"
|
||||
"Omit --global to set the identity only in this repository.\n"
|
||||
"\n");
|
||||
|
||||
static void ident_env_hint(enum want_ident whose_ident)
|
||||
{
|
||||
switch (whose_ident) {
|
||||
case WANT_AUTHOR_IDENT:
|
||||
fputs(_("Author identity unknown\n"), stderr);
|
||||
break;
|
||||
case WANT_COMMITTER_IDENT:
|
||||
fputs(_("Committer identity unknown\n"), stderr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
fputs(_("\n"
|
||||
"*** Please tell me who you are.\n"
|
||||
"\n"
|
||||
"Run\n"
|
||||
"\n"
|
||||
" git config --global user.email \"you@example.com\"\n"
|
||||
" git config --global user.name \"Your Name\"\n"
|
||||
"\n"
|
||||
"to set your account\'s default identity.\n"
|
||||
"Omit --global to set the identity only in this repository.\n"
|
||||
"\n"), stderr);
|
||||
}
|
||||
|
||||
const char *fmt_ident(const char *name, const char *email,
|
||||
enum want_ident whose_ident, const char *date_str, int flag)
|
||||
|
@ -375,12 +389,12 @@ const char *fmt_ident(const char *name, const char *email,
|
|||
if (!email) {
|
||||
if (strict && ident_use_config_only
|
||||
&& !(ident_config_given & IDENT_MAIL_GIVEN)) {
|
||||
fputs(_(env_hint), stderr);
|
||||
ident_env_hint(whose_ident);
|
||||
die(_("no email was given and auto-detection is disabled"));
|
||||
}
|
||||
email = ident_default_email();
|
||||
if (strict && default_email_is_bogus) {
|
||||
fputs(_(env_hint), stderr);
|
||||
ident_env_hint(whose_ident);
|
||||
die(_("unable to auto-detect email address (got '%s')"), email);
|
||||
}
|
||||
}
|
||||
|
@ -397,13 +411,13 @@ const char *fmt_ident(const char *name, const char *email,
|
|||
if (!name) {
|
||||
if (strict && ident_use_config_only
|
||||
&& !(ident_config_given & IDENT_NAME_GIVEN)) {
|
||||
fputs(_(env_hint), stderr);
|
||||
ident_env_hint(whose_ident);
|
||||
die(_("no name was given and auto-detection is disabled"));
|
||||
}
|
||||
name = ident_default_name();
|
||||
using_default = 1;
|
||||
if (strict && default_name_is_bogus) {
|
||||
fputs(_(env_hint), stderr);
|
||||
ident_env_hint(whose_ident);
|
||||
die(_("unable to auto-detect name (got '%s')"), name);
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +425,7 @@ const char *fmt_ident(const char *name, const char *email,
|
|||
struct passwd *pw;
|
||||
if (strict) {
|
||||
if (using_default)
|
||||
fputs(_(env_hint), stderr);
|
||||
ident_env_hint(whose_ident);
|
||||
die(_("empty ident name (for <%s>) not allowed"), email);
|
||||
}
|
||||
pw = xgetpwuid_self(NULL);
|
||||
|
|
|
@ -29,7 +29,18 @@ test_expect_success 'empty configured name does not auto-detect' '
|
|||
sane_unset GIT_AUTHOR_NAME &&
|
||||
test_must_fail \
|
||||
git -c user.name= commit --allow-empty -m foo 2>err &&
|
||||
test_i18ngrep "empty ident name" err
|
||||
test_i18ngrep "empty ident name" err &&
|
||||
test_i18ngrep "Author identity unknown" err
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'empty configured name does not auto-detect for committer' '
|
||||
(
|
||||
sane_unset GIT_COMMITTER_NAME &&
|
||||
test_must_fail \
|
||||
git -c user.name= commit --allow-empty -m foo 2>err &&
|
||||
test_i18ngrep "empty ident name" err &&
|
||||
test_i18ngrep "Committer identity unknown" err
|
||||
)
|
||||
'
|
||||
|
||||
|
|
Loading…
Reference in a new issue