Code

parseopt: add flag to stop on first non option
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Fri, 29 Feb 2008 01:45:09 +0000 (01:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 1 Mar 2008 09:51:44 +0000 (01:51 -0800)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
parse-options.h

index d9562ba5047ff1c9994755a4dbec5162b551c788..be35785ce88e03d23ca5b0e5ffdc6142fb931060 100644 (file)
@@ -249,6 +249,8 @@ int parse_options(int argc, const char **argv, const struct option *options,
                const char *arg = args.argv[0];
 
                if (*arg != '-' || !arg[1]) {
+                       if (flags & PARSE_OPT_STOP_AT_NON_OPTION)
+                               break;
                        argv[j++] = args.argv[0];
                        continue;
                }
index 102ac31fb727acfdc3c2159e1525c7bcca94e1ef..0d40cd2f124edfd68d23c69433e95bd0d5796282 100644 (file)
@@ -18,6 +18,7 @@ enum parse_opt_type {
 
 enum parse_opt_flags {
        PARSE_OPT_KEEP_DASHDASH = 1,
+       PARSE_OPT_STOP_AT_NON_OPTION = 2,
 };
 
 enum parse_opt_option_flags {