add: make warn_pathless_add() a no-op after first call

Make warn_pathless_add() print its warning the first time it is called
and do nothing if called again.  This will make it easier to show the
warning on the fly when a relevant condition is detected without
risking showing it multiple times when multiple such conditions hold.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jonathan Nieder 2013-03-19 15:45:52 -07:00 committed by Junio C Hamano
parent c9f35b8b50
commit 16d41d4218

View file

@ -33,8 +33,13 @@ static const char *short_option_with_implicit_dot;
static void warn_pathless_add(void)
{
static int shown;
assert(option_with_implicit_dot && short_option_with_implicit_dot);
if (shown)
return;
shown = 1;
/*
* To be consistent with "git add -p" and most Git
* commands, we should default to being tree-wide, but