]> git.ipfire.org Git - thirdparty/git.git/commit - ident.c
ident: handle NULL email when complaining of empty name
authorJeff King <peff@peff.net>
Thu, 23 Feb 2017 08:13:53 +0000 (03:13 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Feb 2017 20:46:00 +0000 (12:46 -0800)
commit862e80a413e45d34834ecd573e5c6b39e38ba850
tree9984e9c3c02a25a449e969ffef7b49cabd78358e
parentafb6c30b27069db666a0004f4b6b05c067170088
ident: handle NULL email when complaining of empty name

If we see an empty name, we complain about and mention the
matching email in the error message (to give it some
context). However, the "email" pointer may be NULL here if
we were planning to fill it in later from ident_default_email().

This was broken by 59f929596 (fmt_ident: refactor strictness
checks, 2016-02-04). Prior to that commit, we would look up
the default name and email before doing any other actions.
So one solution would be to go back to that.

However, we can't just do so blindly. The logic for handling
the "!email" condition has grown since then. In particular,
looking up the default email can die if getpwuid() fails,
but there are other errors that should take precedence.
Commit 734c7789a (ident: check for useConfigOnly before
auto-detection of name/email, 2016-03-30) reordered the
checks so that we prefer the error message for
useConfigOnly.

Instead, we can observe that while the name-handling depends
on "email" being set, the reverse is not true. So we can
simply set up the email variable first.

This does mean that if both are bogus, we'll complain about
the email before the name. But between the two, there is no
reason to prefer one over the other.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c
t/t7518-ident-corner-cases.sh [new file with mode: 0755]