From: Jonathan Nieder Date: Tue, 19 Mar 2013 22:45:52 +0000 (-0700) Subject: add: make warn_pathless_add() a no-op after first call X-Git-Tag: v1.8.3-rc0~45^2~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/16d41d42184a4c82d2cd8c41e9eef9784cf437b1?ds=inline;hp=--cc 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 Signed-off-by: Junio C Hamano --- 16d41d42184a4c82d2cd8c41e9eef9784cf437b1 diff --git a/builtin/add.c b/builtin/add.c index c13d548585..bfc6ff3b0a 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -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