parse-options: make sure argh string does not have SP or _
authorJunio C Hamano <gitster@pobox.com>
Sun, 23 Mar 2014 23:04:36 +0000 (16:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Mar 2014 17:43:35 +0000 (10:43 -0700)
We encourage to spell an argument hint that consists of multiple
words as a single-token separated with dashes. In order to help
catching violations added by new callers of parse-options, make sure
argh does not contain SP or _ when the code validates the option
definitions.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
index a5fa0b8938cb2820635bbc620b1b26cc903a6c97..c81d3a06550a1015ab0f4f7284bb48dce0293ab2 100644 (file)
@@ -375,6 +375,9 @@ static void parse_options_check(const struct option *opts)
                default:
                        ; /* ok. (usually accepts an argument) */
                }
+               if (opts->argh &&
+                   strcspn(opts->argh, " _") != strlen(opts->argh))
+                       err |= optbug(opts, "multi-word argh should use dash to separate words");
        }
        if (err)
                exit(128);