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>
This commit is contained in:
Pierre Habouzit
2007-10-14 11:05:12 +02:00
committed by Junio C Hamano
parent ffe659f94d
commit 0ce865b134
2 changed files with 32 additions and 0 deletions

View File

@ -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;
}