]> asedeno.scripts.mit.edu Git - git.git/blobdiff - parse-options.c
Merge branch 'jh/maint-submodule-status-in-void' (early part)
[git.git] / parse-options.c
index 10ec21fb89788e19e6d8d99b29da9801bb406dd3..c83035d013d3f50e9367f2b07d49cf17a1e22ff6 100644 (file)
@@ -2,6 +2,10 @@
 #include "parse-options.h"
 #include "cache.h"
 #include "commit.h"
+#include "color.h"
+
+static int parse_options_usage(const char * const *usagestr,
+                              const struct option *opts);
 
 #define OPT_SHORT 1
 #define OPT_UNSET 2
@@ -560,8 +564,8 @@ void usage_msg_opt(const char *msg,
        usage_with_options(usagestr, options);
 }
 
-int parse_options_usage(const char * const *usagestr,
-                       const struct option *opts)
+static int parse_options_usage(const char * const *usagestr,
+                              const struct option *opts)
 {
        return usage_with_options_internal(usagestr, opts, 0);
 }
@@ -596,6 +600,21 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
        return 0;
 }
 
+int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
+                           int unset)
+{
+       int value;
+
+       if (!arg)
+               arg = unset ? "never" : (const char *)opt->defval;
+       value = git_config_colorbool(NULL, arg, -1);
+       if (value < 0)
+               return opterror(opt,
+                       "expects \"always\", \"auto\", or \"never\"", 0);
+       *(int *)opt->value = value;
+       return 0;
+}
+
 int parse_opt_verbosity_cb(const struct option *opt, const char *arg,
                           int unset)
 {