add: make warn_pathless_add() a no-op after first call
authorJonathan Nieder <jrnieder@gmail.com>
Tue, 19 Mar 2013 22:45:52 +0000 (15:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 18:34:22 +0000 (11:34 -0700)
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>
builtin/add.c
index c13d5485858879a7889e00b0c99372ecd41f1985..bfc6ff3b0a455101f51a0c4a715a831e7b469347 100644 (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