]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-options: make OPT_INTEGER's argh explicit
authorStephen Boyd <bebarino@gmail.com>
Thu, 4 Jun 2009 23:43:56 +0000 (16:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Jun 2009 20:25:01 +0000 (13:25 -0700)
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>
builtin-tag.c
parse-options.c
parse-options.h

index dc3db628115cc7b3c62c1d54af37c87ba126a5db..080e04a8fc6fc1fc3f10f59a4c1f1aa067b81aa1 100644 (file)
@@ -376,8 +376,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        struct commit_list *with_commit = NULL;
        struct option options[] = {
                OPT_BOOLEAN('l', NULL, &list, "list tag names"),
-               { OPTION_INTEGER, 'n', NULL, &lines, NULL,
-                               "print n lines of each tag message",
+               { OPTION_INTEGER, 'n', NULL, &lines, "n",
+                               "print <n> lines of each tag message",
                                PARSE_OPT_OPTARG, NULL, 1 },
                OPT_BOOLEAN('d', NULL, &delete, "delete tags"),
                OPT_BOOLEAN('v', NULL, &verify, "verify tags"),
index b85cab2466244ec3c8ea97dc0882c2971e7b8061..48ba62b0d89a696a17c3e4e8473e34cf6111cd9d 100644 (file)
@@ -503,19 +503,12 @@ int usage_with_options_internal(const char * const *usagestr,
                switch (opts->type) {
                case OPTION_ARGUMENT:
                        break;
-               case OPTION_INTEGER:
-                       if (opts->flags & PARSE_OPT_OPTARG)
-                               if (opts->long_name)
-                                       pos += fprintf(stderr, "[=<n>]");
-                               else
-                                       pos += fprintf(stderr, "[<n>]");
-                       else
-                               pos += fprintf(stderr, " <n>");
-                       break;
                case OPTION_CALLBACK:
                        if (opts->flags & PARSE_OPT_NOARG)
                                break;
                        /* FALLTHROUGH */
+               case OPTION_INTEGER:
+                       /* FALLTHROUGH */
                case OPTION_FILENAME:
                        /* FALLTHROUGH */
                case OPTION_STRING:
index b374ade95c382afd742a32c80338e32cc565cab2..b141ae647a52da2203dff4e06e860ebb778bc49f 100644 (file)
@@ -108,7 +108,7 @@ struct option {
 #define OPT_BOOLEAN(s, l, v, h)     { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
 #define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) }
 #define OPT_SET_PTR(s, l, v, h, p)  { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
-#define OPT_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), NULL, (h) }
+#define OPT_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), "n", (h) }
 #define OPT_STRING(s, l, v, a, h)   { OPTION_STRING,  (s), (l), (v), (a), (h) }
 #define OPT_DATE(s, l, v, h) \
        { OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \