Skip to content

Commit 3e4a67b

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e144d12 commit 3e4a67b

File tree

11 files changed

+47
-50
lines changed

11 files changed

+47
-50
lines changed

archive.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,9 @@ static void parse_treeish_arg(const char **argv,
411411
}
412412

413413
#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)
416415
#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)
419417

420418
static int parse_archive_args(int argc, const char **argv,
421419
const struct archiver **ar, struct archiver_args *args,

builtin/am.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,12 +2231,12 @@ int cmd_am(int argc, const char **argv, const char *prefix)
22312231
N_("pass -b flag to git-mailinfo"), KEEP_NON_PATCH),
22322232
OPT_BOOL('m', "message-id", &state.message_id,
22332233
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),
22402240
OPT_BOOL('c', "scissors", &state.scissors,
22412241
N_("strip everything before a scissors line")),
22422242
OPT_PASSTHRU_ARGV(0, "whitespace", &state.git_apply_opts, N_("action"),

builtin/branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
592592
OPT__QUIET(&quiet, N_("suppress informational messages")),
593593
OPT_SET_INT('t', "track", &track, N_("set up tracking mode (see git-pull(1))"),
594594
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),
597597
OPT_STRING('u', "set-upstream-to", &new_upstream, N_("upstream"), N_("change the upstream info")),
598598
OPT_BOOL(0, "unset-upstream", &unset_upstream, N_("Unset the upstream info")),
599599
OPT__COLOR(&branch_use_color, N_("use colored output")),

builtin/difftool.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,11 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
695695
N_("use `diff.guitool` instead of `diff.tool`")),
696696
OPT_BOOL('d', "dir-diff", &dir_diff,
697697
N_("perform a full-directory diff")),
698-
{ OPTION_SET_INT, 'y', "no-prompt", &prompt, NULL,
698+
OPT_SET_INT_F('y', "no-prompt", &prompt,
699699
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),
704703
OPT_BOOL(0, "symlinks", &symlinks,
705704
N_("use symlinks in dir-diff mode")),
706705
OPT_STRING('t', "tool", &difftool_cmd, N_("<tool>"),

builtin/fetch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ static struct option builtin_fetch_options[] = {
157157
N_("deepen history of shallow clone, excluding rev")),
158158
OPT_INTEGER(0, "deepen", &deepen_relative,
159159
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),
163163
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
164164
N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN },
165165
{ OPTION_CALLBACK, 0, "recurse-submodules-default",

builtin/grep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
885885
N_("indicate hit with exit status without output")),
886886
OPT_BOOL(0, "all-match", &opt.all_match,
887887
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),
891891
OPT_GROUP(""),
892892
{ OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
893893
N_("pager"), N_("show matching files in the pager"),

builtin/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,9 +1474,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
14741474
N_("output all-zero hash in From header")),
14751475
OPT_BOOL(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
14761476
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),
14801480
OPT_GROUP(N_("Messaging")),
14811481
{ OPTION_CALLBACK, 0, "add-header", NULL, N_("header"),
14821482
N_("add email header"), 0, header_callback },

builtin/ls-files.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
556556
{ OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
557557
N_("add the standard git exclusions"),
558558
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),
562562
OPT_BOOL(0, "recurse-submodules", &recurse_submodules,
563563
N_("recurse through submodules")),
564564
OPT_BOOL(0, "error-unmatch", &error_unmatch,

builtin/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ static struct option builtin_merge_options[] = {
213213
OPT_BOOL('e', "edit", &option_edit,
214214
N_("edit message before committing")),
215215
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),
219219
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
220220
OPT_BOOL(0, "verify-signatures", &verify_signatures,
221221
N_("verify that the named commit has a valid GPG signature")),

builtin/notes.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,13 @@ static int merge(int argc, const char **argv, const char *prefix)
778778
N_("resolve notes conflicts using the given strategy "
779779
"(manual/ours/theirs/union/cat_sort_uniq)")),
780780
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),
784784
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),
788788
OPT_END()
789789
};
790790

0 commit comments

Comments
 (0)