X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=parse-options.c;h=9eb55cc8b5182495b687e133a938937db1bc3949;hb=03af0870a0e6d551a31eb830d5c2682b82ae0ac6;hp=fd08bb425c241a0861588ec0aedd15041095a95f;hpb=b43b73666be32ecdc27384d67dc88e4b4869efa1;p=git.git diff --git a/parse-options.c b/parse-options.c index fd08bb425..9eb55cc8b 100644 --- a/parse-options.c +++ b/parse-options.c @@ -484,6 +484,28 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg, return 0; } +int parse_opt_verbosity_cb(const struct option *opt, const char *arg, + int unset) +{ + int *target = opt->value; + + if (unset) + /* --no-quiet, --no-verbose */ + *target = 0; + else if (opt->short_name == 'v') { + if (*target >= 0) + (*target)++; + else + *target = 1; + } else { + if (*target <= 0) + (*target)--; + else + *target = -1; + } + return 0; +} + /* * This should really be OPTION_FILENAME type as a part of * parse_options that take prefix to do this while parsing.