Use OPT_SET_INT_F() for cmdline option specification
The only thing these commands need is extra parseopt flag which can be passed in by OPT_SET_INT_F() and it is a bit more compact than full struct initialization. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 20, 2018 at 17:42 UTC
3e4a67b47d020c8c61d8a762d1903f5288e94778
11 files changed
+47
-50
archive.c
+2
-4
@@ -411,11 +411,9 @@ static void parse_treeish_arg(const char **argv,
411
}
412
413
#define OPT__COMPR(s, v, h, p) \
414
- { OPTION_SET_INT, (s), NULL, (v), NULL, (h), \
415
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, (p) }
414
+ OPT_SET_INT_F(s, NULL, v, h, p, PARSE_OPT_NONEG)
415
#define OPT__COMPR_HIDDEN(s, v, p) \
417
- { OPTION_SET_INT, (s), NULL, (v), NULL, "", \
418
- PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_HIDDEN, NULL, (p) }
416
+ OPT_SET_INT_F(s, NULL, v, "", p, PARSE_OPT_NONEG | PARSE_OPT_HIDDEN)
417
418
static int parse_archive_args(int argc, const char **argv,
419
const struct archiver **ar, struct archiver_args *args,
builtin/am.c
+6
-6
@@ -2231,12 +2231,12 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2231
N_("pass -b flag to git-mailinfo"), KEEP_NON_PATCH),
2232
OPT_BOOL('m', "message-id", &state.message_id,
2233
N_("pass -m flag to git-mailinfo")),
2234
- { OPTION_SET_INT, 0, "keep-cr", &keep_cr, NULL,
2235
- N_("pass --keep-cr flag to git-mailsplit for mbox format"),
2236
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
2237
- { OPTION_SET_INT, 0, "no-keep-cr", &keep_cr, NULL,
2238
- N_("do not pass --keep-cr flag to git-mailsplit independent of am.keepcr"),
2239
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 0},
2234
+ OPT_SET_INT_F(0, "keep-cr", &keep_cr,
2235
+ N_("pass --keep-cr flag to git-mailsplit for mbox format"),
2236
+ 1, PARSE_OPT_NONEG),
2237
+ OPT_SET_INT_F(0, "no-keep-cr", &keep_cr,
2238
+ N_("do not pass --keep-cr flag to git-mailsplit independent of am.keepcr"),
2239
+ 0, PARSE_OPT_NONEG),
2240
OPT_BOOL('c', "scissors", &state.scissors,
2241
N_("strip everything before a scissors line")),
2242
OPT_PASSTHRU_ARGV(0, "whitespace", &state.git_apply_opts, N_("action"),
builtin/branch.c
+2
-2
@@ -592,8 +592,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
592
OPT__QUIET(&quiet, N_("suppress informational messages")),
593
OPT_SET_INT('t', "track", &track, N_("set up tracking mode (see git-pull(1))"),
594
BRANCH_TRACK_EXPLICIT),
595
- { OPTION_SET_INT, 0, "set-upstream", &track, NULL, N_("do not use"),
596
- PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, BRANCH_TRACK_OVERRIDE },
595
+ OPT_SET_INT_F(0, "set-upstream", &track, N_("do not use"),
596
+ BRANCH_TRACK_OVERRIDE, PARSE_OPT_HIDDEN),
597
OPT_STRING('u', "set-upstream-to", &new_upstream, N_("upstream"), N_("change the upstream info")),
598
OPT_BOOL(0, "unset-upstream", &unset_upstream, N_("Unset the upstream info")),
599
OPT__COLOR(&branch_use_color, N_("use colored output")),
builtin/difftool.c
+4
-5
@@ -695,12 +695,11 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
695
N_("use `diff.guitool` instead of `diff.tool`")),
696
OPT_BOOL('d', "dir-diff", &dir_diff,
697
N_("perform a full-directory diff")),
698
- { OPTION_SET_INT, 'y', "no-prompt", &prompt, NULL,
698
+ OPT_SET_INT_F('y', "no-prompt", &prompt,
699
N_("do not prompt before launching a diff tool"),
700
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 0},
701
- { OPTION_SET_INT, 0, "prompt", &prompt, NULL, NULL,
702
- PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_HIDDEN,
703
- NULL, 1 },
700
+ 0, PARSE_OPT_NONEG),
701
+ OPT_SET_INT_F(0, "prompt", &prompt, NULL,
702
+ 1, PARSE_OPT_NONEG | PARSE_OPT_HIDDEN),
703
OPT_BOOL(0, "symlinks", &symlinks,
704
N_("use symlinks in dir-diff mode")),
705
OPT_STRING('t', "tool", &difftool_cmd, N_("<tool>"),
builtin/fetch.c
+3
-3
@@ -157,9 +157,9 @@ static struct option builtin_fetch_options[] = {
157
N_("deepen history of shallow clone, excluding rev")),
158
OPT_INTEGER(0, "deepen", &deepen_relative,
159
N_("deepen history of shallow clone")),
160
- { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL,
161
- N_("convert to a complete repository"),
162
- PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 },
160
+ OPT_SET_INT_F(0, "unshallow", &unshallow,
161
+ N_("convert to a complete repository"),
162
+ 1, PARSE_OPT_NONEG),
163
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
164
N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN },
165
{ OPTION_CALLBACK, 0, "recurse-submodules-default",
builtin/grep.c
+3
-3
@@ -885,9 +885,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
885
N_("indicate hit with exit status without output")),
886
OPT_BOOL(0, "all-match", &opt.all_match,
887
N_("show only matches from files that match all patterns")),
888
- { OPTION_SET_INT, 0, "debug", &opt.debug, NULL,
889
- N_("show parse tree for grep expression"),
890
- PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1 },
888
+ OPT_SET_INT_F(0, "debug", &opt.debug,
889
+ N_("show parse tree for grep expression"),
890
+ 1, PARSE_OPT_HIDDEN),
891
OPT_GROUP(""),
892
{ OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
893
N_("pager"), N_("show matching files in the pager"),
builtin/log.c
+3
-3
@@ -1474,9 +1474,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1474
N_("output all-zero hash in From header")),
1475
OPT_BOOL(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
1476
N_("don't include a patch matching a commit upstream")),
1477
- { OPTION_SET_INT, 'p', "no-stat", &use_patch_format, NULL,
1478
- N_("show patch format instead of default (patch + stat)"),
1479
- PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1},
1477
+ OPT_SET_INT_F('p', "no-stat", &use_patch_format,
1478
+ N_("show patch format instead of default (patch + stat)"),
1479
+ 1, PARSE_OPT_NONEG),
1480
OPT_GROUP(N_("Messaging")),
1481
{ OPTION_CALLBACK, 0, "add-header", NULL, N_("header"),
1482
N_("add email header"), 0, header_callback },
builtin/ls-files.c
+3
-3
@@ -556,9 +556,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
556
{ OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
557
N_("add the standard git exclusions"),
558
PARSE_OPT_NOARG, option_parse_exclude_standard },
559
- { OPTION_SET_INT, 0, "full-name", &prefix_len, NULL,
560
- N_("make the output relative to the project top directory"),
561
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL },
559
+ OPT_SET_INT_F(0, "full-name", &prefix_len,
560
+ N_("make the output relative to the project top directory"),
561
+ 0, PARSE_OPT_NONEG),
562
OPT_BOOL(0, "recurse-submodules", &recurse_submodules,
563
N_("recurse through submodules")),
564
OPT_BOOL(0, "error-unmatch", &error_unmatch,
builtin/merge.c
+3
-3
@@ -213,9 +213,9 @@ static struct option builtin_merge_options[] = {
213
OPT_BOOL('e', "edit", &option_edit,
214
N_("edit message before committing")),
215
OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW),
216
- { OPTION_SET_INT, 0, "ff-only", &fast_forward, NULL,
217
- N_("abort if fast-forward is not possible"),
218
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
216
+ OPT_SET_INT_F(0, "ff-only", &fast_forward,
217
+ N_("abort if fast-forward is not possible"),
218
+ FF_ONLY, PARSE_OPT_NONEG),
219
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
220
OPT_BOOL(0, "verify-signatures", &verify_signatures,
221
N_("verify that the named commit has a valid GPG signature")),
builtin/notes.c
+6
-6
@@ -778,13 +778,13 @@ static int merge(int argc, const char **argv, const char *prefix)
778
N_("resolve notes conflicts using the given strategy "
779
"(manual/ours/theirs/union/cat_sort_uniq)")),
780
OPT_GROUP(N_("Committing unmerged notes")),
781
- { OPTION_SET_INT, 0, "commit", &do_commit, NULL,
782
- N_("finalize notes merge by committing unmerged notes"),
783
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
781
+ OPT_SET_INT_F(0, "commit", &do_commit,
782
+ N_("finalize notes merge by committing unmerged notes"),
783
+ 1, PARSE_OPT_NONEG),
784
OPT_GROUP(N_("Aborting notes merge resolution")),
785
- { OPTION_SET_INT, 0, "abort", &do_abort, NULL,
786
- N_("abort notes merge"),
787
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
785
+ OPT_SET_INT_F(0, "abort", &do_abort,
786
+ N_("abort notes merge"),
787
+ 1, PARSE_OPT_NONEG),
788
OPT_END()
789
};
790
builtin/pack-objects.c
+12
-12
@@ -3132,18 +3132,18 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3132
N_("do not create an empty pack output")),
3133
OPT_BOOL(0, "revs", &use_internal_rev_list,
3134
N_("read revision arguments from standard input")),
3135
- { OPTION_SET_INT, 0, "unpacked", &rev_list_unpacked, NULL,
3136
- N_("limit the objects to those that are not yet packed"),
3137
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
3138
- { OPTION_SET_INT, 0, "all", &rev_list_all, NULL,
3139
- N_("include objects reachable from any reference"),
3140
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
3141
- { OPTION_SET_INT, 0, "reflog", &rev_list_reflog, NULL,
3142
- N_("include objects referred by reflog entries"),
3143
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
3144
- { OPTION_SET_INT, 0, "indexed-objects", &rev_list_index, NULL,
3145
- N_("include objects referred to by the index"),
3146
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
3135
+ OPT_SET_INT_F(0, "unpacked", &rev_list_unpacked,
3136
+ N_("limit the objects to those that are not yet packed"),
3137
+ 1, PARSE_OPT_NONEG),
3138
+ OPT_SET_INT_F(0, "all", &rev_list_all,
3139
+ N_("include objects reachable from any reference"),
3140
+ 1, PARSE_OPT_NONEG),
3141
+ OPT_SET_INT_F(0, "reflog", &rev_list_reflog,
3142
+ N_("include objects referred by reflog entries"),
3143
+ 1, PARSE_OPT_NONEG),
3144
+ OPT_SET_INT_F(0, "indexed-objects", &rev_list_index,
3145
+ N_("include objects referred to by the index"),
3146
+ 1, PARSE_OPT_NONEG),
3147
OPT_BOOL(0, "stdout", &pack_to_stdout,
3148
N_("output pack to stdout")),
3149
OPT_BOOL(0, "include-tag", &include_tag,