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>
Jonathan Nieder committed
Mar 19, 2013 at 15:45 UTC
16d41d42184a4c82d2cd8c41e9eef9784cf437b1
1 file changed
+5
builtin/add.c
+5
@@ -33,8 +33,13 @@ static const char *short_option_with_implicit_dot;
33
34
static void warn_pathless_add(void)
35
{
36
+ static int shown;
37
assert(option_with_implicit_dot && short_option_with_implicit_dot);
38
39
+ if (shown)
40
+ return;
41
+ shown = 1;
42
+
43
/*
44
* To be consistent with "git add -p" and most Git
45
* commands, we should default to being tree-wide, but