parse-options: make OPT_INTEGER's argh explicit
OPTION_INTEGER hardcodes its argh member to be "n", but the decision is hidden deep in usage_with_options_internal(). Make "n" the default argh for the OPT_INTEGER macro while leaving it undecided for the OPTION_INTEGER enum. This makes it less surprising to users that argh is "n" when using the OPT_INTEGER macro. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Reviewed-by: René Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen Boyd committed
Jun 4, 2009 at 16:43 UTC
e3a0ca878457ecc70d0065802fcb0c6875c6b671
3 files changed
+5
-12
builtin-tag.c
+2
-2
@@ -376,8 +376,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
376
struct commit_list *with_commit = NULL;
377
struct option options[] = {
378
OPT_BOOLEAN('l', NULL, &list, "list tag names"),
379
- { OPTION_INTEGER, 'n', NULL, &lines, NULL,
380
- "print n lines of each tag message",
379
+ { OPTION_INTEGER, 'n', NULL, &lines, "n",
380
+ "print <n> lines of each tag message",
381
PARSE_OPT_OPTARG, NULL, 1 },
382
OPT_BOOLEAN('d', NULL, &delete, "delete tags"),
383
OPT_BOOLEAN('v', NULL, &verify, "verify tags"),
parse-options.c
+2
-9
@@ -503,19 +503,12 @@ int usage_with_options_internal(const char * const *usagestr,
503
switch (opts->type) {
504
case OPTION_ARGUMENT:
505
break;
506
- case OPTION_INTEGER:
507
- if (opts->flags & PARSE_OPT_OPTARG)
508
- if (opts->long_name)
509
- pos += fprintf(stderr, "[=<n>]");
510
- else
511
- pos += fprintf(stderr, "[<n>]");
512
- else
513
- pos += fprintf(stderr, " <n>");
514
- break;
506
case OPTION_CALLBACK:
507
if (opts->flags & PARSE_OPT_NOARG)
508
break;
509
/* FALLTHROUGH */
510
+ case OPTION_INTEGER:
511
+ /* FALLTHROUGH */
512
case OPTION_FILENAME:
513
/* FALLTHROUGH */
514
case OPTION_STRING:
parse-options.h
+1
-1
@@ -108,7 +108,7 @@ struct option {
108
#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
109
#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) }
110
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
111
-#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) }
111
+#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) }
112
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
113
#define OPT_DATE(s, l, v, h) \
114
{ OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \