summaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
authorLibravatar Marios Titas <redneb@gmx.com>2016-03-30 22:29:42 +0300
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-04-01 14:57:55 -0700
commit734c7789aa1055d465e336f618889cc6df478535 (patch)
tree7e1ff05213579300ac42c1f29646f8655993198c /ident.c
parentident: add user.useConfigOnly boolean for when ident shouldn't be guessed (diff)
downloadtgif-734c7789aa1055d465e336f618889cc6df478535.tar.xz
ident: check for useConfigOnly before auto-detection of name/email
If user.useConfigOnly is set, it does not make sense to try to auto-detect the name and/or the email. The auto-detection may even result in a bogus name and trigger an error message. Check if the use-config-only is set and die if no explicit name was given, before attempting to auto-detect, to correct this. Signed-off-by: Marios Titas <redneb@gmx.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ident.c b/ident.c
index 4bd80842bc..b2521ffc01 100644
--- a/ident.c
+++ b/ident.c
@@ -351,15 +351,15 @@ const char *fmt_ident(const char *name, const char *email,
if (want_name) {
int using_default = 0;
if (!name) {
+ if (strict && ident_use_config_only
+ && !(ident_config_given & IDENT_NAME_GIVEN))
+ die("user.useConfigOnly set but no name given");
name = ident_default_name();
using_default = 1;
if (strict && default_name_is_bogus) {
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;
@@ -374,14 +374,14 @@ const char *fmt_ident(const char *name, const char *email,
}
if (!email) {
+ if (strict && ident_use_config_only
+ && !(ident_config_given & IDENT_MAIL_GIVEN))
+ die("user.useConfigOnly set but no mail given");
email = ident_default_email();
if (strict && default_email_is_bogus) {
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);