summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-10-14 09:05:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-10-30 04:03:30 (GMT)
commit0ce865b134f8ccd60f6e584744144b0978a9fdf2 (patch)
tree0a3d70424a322ea6302dbb5a522561eebb434dcd /parse-options.c
parentffe659f94d793375fca97dd296422fc10c155016 (diff)
downloadgit-0ce865b134f8ccd60f6e584744144b0978a9fdf2.zip
git-0ce865b134f8ccd60f6e584744144b0978a9fdf2.tar.gz
git-0ce865b134f8ccd60f6e584744144b0978a9fdf2.tar.bz2
Add shortcuts for very often used options.
It helps with consistency of the help strings, for example. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index c751ebf..12a9f9e 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -254,3 +254,24 @@ void usage_with_options(const char * const *usagestr,
exit(129);
}
+
+/*----- some often used options -----*/
+#include "cache.h"
+int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
+{
+ int v;
+
+ if (!arg) {
+ v = unset ? 0 : DEFAULT_ABBREV;
+ } else {
+ v = strtol(arg, (char **)&arg, 10);
+ if (*arg)
+ return opterror(opt, "expects a numerical value", 0);
+ if (v && v < MINIMUM_ABBREV)
+ v = MINIMUM_ABBREV;
+ else if (v > 40)
+ v = 40;
+ }
+ *(int *)(opt->value) = v;
+ return 0;
+}