fmt_ident: refactor strictness checks
commit59f929596b611d88270ac0fd3ea132b32d66d460
authorJeff King <peff@peff.net>
Thu, 4 Feb 2016 09:12:38 +0000 (4 11:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Feb 2016 21:18:48 +0000 (4 13:18 -0800)
tree85e899a9409daa95fbb0a73e50c6c46bdb9d5125
parent754884255bb580df159e58defa81cdd30b5c430c
fmt_ident: refactor strictness checks

This function has evolved quite a bit over time, and as a
result, the logic for "is this an OK ident" has been
sprinkled throughout. This ends up with a lot of redundant
conditionals, like checking want_name repeatedly. Worse,
we want to know in many cases whether we are using the
"default" ident, and we do so by comparing directly to the
global strbuf, which violates the abstraction of the
ident_default_* functions.

Let's reorganize the function into a hierarchy of
conditionals to handle similar cases together. The only
case that doesn't just work naturally for this is that of an
empty name, where our advice is different based on whether
we came from ident_default_name() or not. We can use a
simple flag to cover this case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c