@matheusbsbs / matheus-bagliano / commits / 203c85339f
Fork 0

Use OPT_CALLBACK and OPT_CALLBACK_F

In the codebase, there are many options which use OPTION_CALLBACK in a plain ol' struct definition. However, we have the OPT_CALLBACK and OPT_CALLBACK_F macros which are meant to abstract these plain struct definitions away. These macros are useful as they semantically signal to developers that these are just normal callback option with nothing fancy happening. Replace plain struct definitions of OPTION_CALLBACK with OPT_CALLBACK or OPT_CALLBACK_F where applicable. The heavy lifting was done using the following (disgusting) shell script: #!/bin/sh do_replacement () { tr '\n' '\r' | sed -e 's/{\s*OPTION_CALLBACK,\s*\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\s*0,\(\s*[^[:space:]}]*\)\s*}/OPT_CALLBACK(\1,\2,\3,\4,\5,\6)/g' | sed -e 's/{\s*OPTION_CALLBACK,\s*\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\(\s*[^[:space:]}]*\)\s*}/OPT_CALLBACK_F(\1,\2,\3,\4,\5,\6,\7)/g' | tr '\r' '\n' } for f in $(git ls-files \*.c) do do_replacement <"$f" >"$f.tmp" mv "$f.tmp" "$f" done The result was manually inspected and then reformatted to match the style of the surrounding code. Finally, using `git grep OPTION_CALLBACK \*.c`, leftover results which were not handled by the script were manually transformed. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Apr 28, 2020 at 04:36 UTC 203c85339fb51bb8b83aae8f0adde44d6e55e018
31 files changed +173 -181
apply.c
+14 -14
@@ -4964,15 +4964,15 @@ int apply_parse_options(int argc, const char **argv,
4964 const char * const *apply_usage)
4965 {
4966 struct option builtin_apply_options[] = {
4967 - { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
4967 + OPT_CALLBACK_F(0, "exclude", state, N_("path"),
4968 N_("don't apply changes matching the given path"),
4969 - PARSE_OPT_NONEG, apply_option_parse_exclude },
4970 - { OPTION_CALLBACK, 0, "include", state, N_("path"),
4969 + PARSE_OPT_NONEG, apply_option_parse_exclude),
4970 + OPT_CALLBACK_F(0, "include", state, N_("path"),
4971 N_("apply changes matching the given path"),
4972 - PARSE_OPT_NONEG, apply_option_parse_include },
4973 - { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
4972 + PARSE_OPT_NONEG, apply_option_parse_include),
4973 + OPT_CALLBACK('p', NULL, state, N_("num"),
4974 N_("remove <num> leading slashes from traditional diff paths"),
4975 - 0, apply_option_parse_p },
4975 + apply_option_parse_p),
4976 OPT_BOOL(0, "no-add", &state->no_add,
4977 N_("ignore additions made by the patch")),
4978 OPT_BOOL(0, "stat", &state->diffstat,
@@ -5005,15 +5005,15 @@ int apply_parse_options(int argc, const char **argv,
5005 N_("paths are separated with NUL character"), '\0'),
5006 OPT_INTEGER('C', NULL, &state->p_context,
5007 N_("ensure at least <n> lines of context match")),
5008 - { OPTION_CALLBACK, 0, "whitespace", state, N_("action"),
5008 + OPT_CALLBACK(0, "whitespace", state, N_("action"),
5009 N_("detect new or modified lines that have whitespace errors"),
5010 - 0, apply_option_parse_whitespace },
5011 - { OPTION_CALLBACK, 0, "ignore-space-change", state, NULL,
5010 + apply_option_parse_whitespace),
5011 + OPT_CALLBACK_F(0, "ignore-space-change", state, NULL,
5012 N_("ignore changes in whitespace when finding context"),
5013 - PARSE_OPT_NOARG, apply_option_parse_space_change },
5014 - { OPTION_CALLBACK, 0, "ignore-whitespace", state, NULL,
5013 + PARSE_OPT_NOARG, apply_option_parse_space_change),
5014 + OPT_CALLBACK_F(0, "ignore-whitespace", state, NULL,
5015 N_("ignore changes in whitespace when finding context"),
5016 - PARSE_OPT_NOARG, apply_option_parse_space_change },
5016 + PARSE_OPT_NOARG, apply_option_parse_space_change),
5017 OPT_BOOL('R', "reverse", &state->apply_in_reverse,
5018 N_("apply the patch in reverse")),
5019 OPT_BOOL(0, "unidiff-zero", &state->unidiff_zero,
@@ -5029,9 +5029,9 @@ int apply_parse_options(int argc, const char **argv,
5029 OPT_BIT(0, "recount", options,
5030 N_("do not trust the line counts in the hunk headers"),
5031 APPLY_OPT_RECOUNT),
5032 - { OPTION_CALLBACK, 0, "directory", state, N_("root"),
5032 + OPT_CALLBACK(0, "directory", state, N_("root"),
5033 N_("prepend <root> to all filenames"),
5034 - 0, apply_option_parse_directory },
5034 + apply_option_parse_directory),
5035 OPT_END()
5036 };
5037
builtin/add.c
+2 -2
@@ -330,10 +330,10 @@ static struct option builtin_add_options[] = {
330 OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
331 OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
332 OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
333 - { OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit,
333 + OPT_CALLBACK_F(0, "ignore-removal", &addremove_explicit,
334 NULL /* takes no arguments */,
335 N_("ignore paths removed in the working tree (same as --no-all)"),
336 - PARSE_OPT_NOARG, ignore_removal_cb },
336 + PARSE_OPT_NOARG, ignore_removal_cb),
337 OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
338 OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
339 OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
builtin/blame.c
+2 -2
@@ -864,8 +864,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
864 OPT_BIT(0, "minimal", &xdl_opts, N_("Spend extra cycles to find better match"), XDF_NEED_MINIMAL),
865 OPT_STRING('S', NULL, &revs_file, N_("file"), N_("Use revisions from <file> instead of calling git-rev-list")),
866 OPT_STRING(0, "contents", &contents_from, N_("file"), N_("Use <file>'s contents as the final image")),
867 - { OPTION_CALLBACK, 'C', NULL, &opt, N_("score"), N_("Find line copies within and across files"), PARSE_OPT_OPTARG, blame_copy_callback },
868 - { OPTION_CALLBACK, 'M', NULL, &opt, N_("score"), N_("Find line movements within and across files"), PARSE_OPT_OPTARG, blame_move_callback },
867 + OPT_CALLBACK_F('C', NULL, &opt, N_("score"), N_("Find line copies within and across files"), PARSE_OPT_OPTARG, blame_copy_callback),
868 + OPT_CALLBACK_F('M', NULL, &opt, N_("score"), N_("Find line movements within and across files"), PARSE_OPT_OPTARG, blame_move_callback),
869 OPT_STRING_LIST('L', NULL, &range_list, N_("n,m"), N_("Process only line range n,m, counting from 1")),
870 OPT__ABBREV(&abbrev),
871 OPT_END()
builtin/branch.c
+2 -4
@@ -653,10 +653,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
653 OPT_NO_MERGED(&filter, N_("print only branches that are not merged")),
654 OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),
655 OPT_REF_SORT(sorting_tail),
656 - {
657 - OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
658 - N_("print only branches of the object"), 0, parse_opt_object_name
659 - },
656 + OPT_CALLBACK(0, "points-at", &filter.points_at, N_("object"),
657 + N_("print only branches of the object"), parse_opt_object_name),
658 OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
659 OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")),
660 OPT_END(),
builtin/cat-file.c
+4 -4
@@ -650,14 +650,14 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
650 OPT_BOOL(0, "allow-unknown-type", &unknown_type,
651 N_("allow -s and -t to work with broken/corrupt objects")),
652 OPT_BOOL(0, "buffer", &batch.buffer_output, N_("buffer --batch output")),
653 - { OPTION_CALLBACK, 0, "batch", &batch, "format",
653 + OPT_CALLBACK_F(0, "batch", &batch, "format",
654 N_("show info and content of objects fed from the standard input"),
655 PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
656 - batch_option_callback },
657 - { OPTION_CALLBACK, 0, "batch-check", &batch, "format",
656 + batch_option_callback),
657 + OPT_CALLBACK_F(0, "batch-check", &batch, "format",
658 N_("show info about objects fed from the standard input"),
659 PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
660 - batch_option_callback },
660 + batch_option_callback),
661 OPT_BOOL(0, "follow-symlinks", &batch.follow_symlinks,
662 N_("follow in-tree symlinks (used with --batch or --batch-check)")),
663 OPT_BOOL(0, "batch-all-objects", &batch.all_objects,
builtin/checkout-index.c
+2 -2
@@ -177,9 +177,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
177 N_("write the content to temporary files")),
178 OPT_STRING(0, "prefix", &state.base_dir, N_("string"),
179 N_("when creating files, prepend <string>")),
180 - { OPTION_CALLBACK, 0, "stage", NULL, "(1|2|3|all)",
180 + OPT_CALLBACK_F(0, "stage", NULL, "(1|2|3|all)",
181 N_("copy out the files from named stage"),
182 - PARSE_OPT_NONEG, option_parse_stage },
182 + PARSE_OPT_NONEG, option_parse_stage),
183 OPT_END()
184 };
185
builtin/checkout.c
+2 -2
@@ -1486,9 +1486,9 @@ static struct option *add_common_options(struct checkout_opts *opts,
1486 {
1487 struct option options[] = {
1488 OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
1489 - { OPTION_CALLBACK, 0, "recurse-submodules", NULL,
1489 + OPT_CALLBACK_F(0, "recurse-submodules", NULL,
1490 "checkout", "control recursive updating of submodules",
1491 - PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater },
1491 + PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
1492 OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")),
1493 OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")),
1494 OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
builtin/clean.c
+2 -2
@@ -906,8 +906,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
906 OPT_BOOL('i', "interactive", &interactive, N_("interactive cleaning")),
907 OPT_BOOL('d', NULL, &remove_directories,
908 N_("remove whole directories")),
909 - { OPTION_CALLBACK, 'e', "exclude", &exclude_list, N_("pattern"),
910 - N_("add <pattern> to ignore rules"), PARSE_OPT_NONEG, exclude_cb },
909 + OPT_CALLBACK_F('e', "exclude", &exclude_list, N_("pattern"),
910 + N_("add <pattern> to ignore rules"), PARSE_OPT_NONEG, exclude_cb),
911 OPT_BOOL('x', NULL, &ignored, N_("remove ignored files, too")),
912 OPT_BOOL('X', NULL, &ignored_only,
913 N_("remove only ignored files")),
builtin/commit-tree.c
+6 -6
@@ -108,15 +108,15 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
108 struct object_id commit_oid;
109
110 struct option options[] = {
111 - { OPTION_CALLBACK, 'p', NULL, &parents, N_("parent"),
111 + OPT_CALLBACK_F('p', NULL, &parents, N_("parent"),
112 N_("id of a parent commit object"), PARSE_OPT_NONEG,
113 - parse_parent_arg_callback },
114 - { OPTION_CALLBACK, 'm', NULL, &buffer, N_("message"),
113 + parse_parent_arg_callback),
114 + OPT_CALLBACK_F('m', NULL, &buffer, N_("message"),
115 N_("commit message"), PARSE_OPT_NONEG,
116 - parse_message_arg_callback },
117 - { OPTION_CALLBACK, 'F', NULL, &buffer, N_("file"),
116 + parse_message_arg_callback),
117 + OPT_CALLBACK_F('F', NULL, &buffer, N_("file"),
118 N_("read commit log message from file"), PARSE_OPT_NONEG,
119 - parse_file_arg_callback },
119 + parse_file_arg_callback),
120 { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
121 N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
122 OPT_END()
builtin/commit.c
+4 -4
@@ -1372,9 +1372,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1372 N_("show stash information")),
1373 OPT_BOOL(0, "ahead-behind", &s.ahead_behind_flags,
1374 N_("compute full ahead/behind values")),
1375 - { OPTION_CALLBACK, 0, "porcelain", &status_format,
1375 + OPT_CALLBACK_F(0, "porcelain", &status_format,
1376 N_("version"), N_("machine-readable output"),
1377 - PARSE_OPT_OPTARG, opt_parse_porcelain },
1377 + PARSE_OPT_OPTARG, opt_parse_porcelain),
1378 OPT_SET_INT(0, "long", &status_format,
1379 N_("show status in long format (default)"),
1380 STATUS_FORMAT_LONG),
@@ -1393,9 +1393,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1393 PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
1394 OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
1395 OPT_BOOL(0, "no-renames", &no_renames, N_("do not detect renames")),
1396 - { OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
1396 + OPT_CALLBACK_F('M', "find-renames", &rename_score_arg,
1397 N_("n"), N_("detect renames, optionally set similarity index"),
1398 - PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score },
1398 + PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score),
1399 OPT_END(),
1400 };
1401
builtin/fetch.c
+6 -6
@@ -156,9 +156,9 @@ static struct option builtin_fetch_options[] = {
156 N_("prune remote-tracking branches no longer on remote")),
157 OPT_BOOL('P', "prune-tags", &prune_tags,
158 N_("prune local tags no longer on remote and clobber changed tags")),
159 - { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("on-demand"),
159 + OPT_CALLBACK_F(0, "recurse-submodules", &recurse_submodules, N_("on-demand"),
160 N_("control recursive fetching of submodules"),
161 - PARSE_OPT_OPTARG, option_fetch_parse_recurse_submodules },
161 + PARSE_OPT_OPTARG, option_fetch_parse_recurse_submodules),
162 OPT_BOOL(0, "dry-run", &dry_run,
163 N_("dry run")),
164 OPT_BOOL('k', "keep", &keep, N_("keep downloaded pack")),
@@ -178,15 +178,15 @@ static struct option builtin_fetch_options[] = {
178 1, PARSE_OPT_NONEG),
179 { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
180 N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN },
181 - { OPTION_CALLBACK, 0, "recurse-submodules-default",
181 + OPT_CALLBACK_F(0, "recurse-submodules-default",
182 &recurse_submodules_default, N_("on-demand"),
183 N_("default for recursive fetching of submodules "
184 "(lower priority than config files)"),
185 - PARSE_OPT_HIDDEN, option_fetch_parse_recurse_submodules },
185 + PARSE_OPT_HIDDEN, option_fetch_parse_recurse_submodules),
186 OPT_BOOL(0, "update-shallow", &update_shallow,
187 N_("accept refs that update .git/shallow")),
188 - { OPTION_CALLBACK, 0, "refmap", NULL, N_("refmap"),
189 - N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg },
188 + OPT_CALLBACK_F(0, "refmap", NULL, N_("refmap"),
189 + N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg),
190 OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")),
191 OPT_SET_INT('4', "ipv4", &family, N_("use IPv4 addresses only"),
192 TRANSPORT_FAMILY_IPV4),
builtin/grep.c
+13 -13
@@ -886,20 +886,20 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
886 OPT_GROUP(""),
887 OPT_CALLBACK('f', NULL, &opt, N_("file"),
888 N_("read patterns from file"), file_callback),
889 - { OPTION_CALLBACK, 'e', NULL, &opt, N_("pattern"),
890 - N_("match <pattern>"), PARSE_OPT_NONEG, pattern_callback },
891 - { OPTION_CALLBACK, 0, "and", &opt, NULL,
892 - N_("combine patterns specified with -e"),
893 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, and_callback },
889 + OPT_CALLBACK_F('e', NULL, &opt, N_("pattern"),
890 + N_("match <pattern>"), PARSE_OPT_NONEG, pattern_callback),
891 + OPT_CALLBACK_F(0, "and", &opt, NULL,
892 + N_("combine patterns specified with -e"),
893 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, and_callback),
894 OPT_BOOL(0, "or", &dummy, ""),
895 - { OPTION_CALLBACK, 0, "not", &opt, NULL, "",
896 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, not_callback },
897 - { OPTION_CALLBACK, '(', NULL, &opt, NULL, "",
898 - PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
899 - open_callback },
900 - { OPTION_CALLBACK, ')', NULL, &opt, NULL, "",
901 - PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
902 - close_callback },
895 + OPT_CALLBACK_F(0, "not", &opt, NULL, "",
896 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, not_callback),
897 + OPT_CALLBACK_F('(', NULL, &opt, NULL, "",
898 + PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
899 + open_callback),
900 + OPT_CALLBACK_F(')', NULL, &opt, NULL, "",
901 + PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
902 + close_callback),
903 OPT__QUIET(&opt.status_only,
904 N_("indicate hit with exit status without output")),
905 OPT_BOOL(0, "all-match", &opt.all_match,
builtin/interpret-trailers.c
+2 -2
@@ -105,8 +105,8 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
105 OPT_BOOL(0, "only-trailers", &opts.only_trailers, N_("output only the trailers")),
106 OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply config rules")),
107 OPT_BOOL(0, "unfold", &opts.unfold, N_("join whitespace-continued values")),
108 - { OPTION_CALLBACK, 0, "parse", &opts, NULL, N_("set parsing options"),
109 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_parse },
108 + OPT_CALLBACK_F(0, "parse", &opts, NULL, N_("set parsing options"),
109 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_parse),
110 OPT_BOOL(0, "no-divider", &opts.no_divider, N_("do not treat --- specially")),
111 OPT_CALLBACK(0, "trailer", &trailers, N_("trailer"),
112 N_("trailer(s) to add"), option_parse_trailer),
builtin/log.c
+26 -28
@@ -179,8 +179,8 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
179 N_("pattern"), N_("only decorate refs that match <pattern>")),
180 OPT_STRING_LIST(0, "decorate-refs-exclude", &decorate_refs_exclude,
181 N_("pattern"), N_("do not decorate refs that match <pattern>")),
182 - { OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),
183 - PARSE_OPT_OPTARG, decorate_callback},
182 + OPT_CALLBACK_F(0, "decorate", NULL, NULL, N_("decorate options"),
183 + PARSE_OPT_OPTARG, decorate_callback),
184 OPT_CALLBACK('L', NULL, &line_cb, "n,m:file",
185 N_("Process line range n,m in file, counting from 1"),
186 log_line_range_callback),
@@ -1631,12 +1631,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1631 int creation_factor = -1;
1632
1633 const struct option builtin_format_patch_options[] = {
1634 - { OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
1634 + OPT_CALLBACK_F('n', "numbered", &numbered, NULL,
1635 N_("use [PATCH n/m] even with a single patch"),
1636 - PARSE_OPT_NOARG, numbered_callback },
1637 - { OPTION_CALLBACK, 'N', "no-numbered", &numbered, NULL,
1636 + PARSE_OPT_NOARG, numbered_callback),
1637 + OPT_CALLBACK_F('N', "no-numbered", &numbered, NULL,
1638 N_("use [PATCH] even with multiple patches"),
1639 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, no_numbered_callback },
1639 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, no_numbered_callback),
1640 OPT_BOOL('s', "signoff", &do_signoff, N_("add Signed-off-by:")),
1641 OPT_BOOL(0, "stdout", &use_stdout,
1642 N_("print patches to standard out")),
@@ -1650,21 +1650,21 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1650 N_("start numbering patches at <n> instead of 1")),
1651 OPT_INTEGER('v', "reroll-count", &reroll_count,
1652 N_("mark the series as Nth re-roll")),
1653 - { OPTION_CALLBACK, 0, "rfc", &rev, NULL,
1653 + OPT_CALLBACK_F(0, "rfc", &rev, NULL,
1654 N_("Use [RFC PATCH] instead of [PATCH]"),
1655 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback },
1655 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
1656 OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
1657 N_("cover-from-description-mode"),
1658 N_("generate parts of a cover letter based on a branch's description")),
1659 - { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
1659 + OPT_CALLBACK_F(0, "subject-prefix", &rev, N_("prefix"),
1660 N_("Use [<prefix>] instead of [PATCH]"),
1661 - PARSE_OPT_NONEG, subject_prefix_callback },
1662 - { OPTION_CALLBACK, 'o', "output-directory", &output_directory,
1661 + PARSE_OPT_NONEG, subject_prefix_callback),
1662 + OPT_CALLBACK_F('o', "output-directory", &output_directory,
1663 N_("dir"), N_("store resulting files in <dir>"),
1664 - PARSE_OPT_NONEG, output_directory_callback },
1665 - { OPTION_CALLBACK, 'k', "keep-subject", &rev, NULL,
1664 + PARSE_OPT_NONEG, output_directory_callback),
1665 + OPT_CALLBACK_F('k', "keep-subject", &rev, NULL,
1666 N_("don't strip/add [PATCH]"),
1667 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback },
1667 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback),
1668 OPT_BOOL(0, "no-binary", &no_binary_diff,
1669 N_("don't output binary diffs")),
1670 OPT_BOOL(0, "zero-commit", &zero_commit,
@@ -1675,27 +1675,25 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1675 N_("show patch format instead of default (patch + stat)"),
1676 1, PARSE_OPT_NONEG),
1677 OPT_GROUP(N_("Messaging")),
1678 - { OPTION_CALLBACK, 0, "add-header", NULL, N_("header"),
1679 - N_("add email header"), 0, header_callback },
1680 - { OPTION_CALLBACK, 0, "to", NULL, N_("email"), N_("add To: header"),
1681 - 0, to_callback },
1682 - { OPTION_CALLBACK, 0, "cc", NULL, N_("email"), N_("add Cc: header"),
1683 - 0, cc_callback },
1684 - { OPTION_CALLBACK, 0, "from", &from, N_("ident"),
1678 + OPT_CALLBACK(0, "add-header", NULL, N_("header"),
1679 + N_("add email header"), header_callback),
1680 + OPT_CALLBACK(0, "to", NULL, N_("email"), N_("add To: header"), to_callback),
1681 + OPT_CALLBACK(0, "cc", NULL, N_("email"), N_("add Cc: header"), cc_callback),
1682 + OPT_CALLBACK_F(0, "from", &from, N_("ident"),
1683 N_("set From address to <ident> (or committer ident if absent)"),
1686 - PARSE_OPT_OPTARG, from_callback },
1684 + PARSE_OPT_OPTARG, from_callback),
1685 OPT_STRING(0, "in-reply-to", &in_reply_to, N_("message-id"),
1686 N_("make first mail a reply to <message-id>")),
1689 - { OPTION_CALLBACK, 0, "attach", &rev, N_("boundary"),
1687 + OPT_CALLBACK_F(0, "attach", &rev, N_("boundary"),
1688 N_("attach the patch"), PARSE_OPT_OPTARG,
1691 - attach_callback },
1692 - { OPTION_CALLBACK, 0, "inline", &rev, N_("boundary"),
1689 + attach_callback),
1690 + OPT_CALLBACK_F(0, "inline", &rev, N_("boundary"),
1691 N_("inline the patch"),
1692 PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
1695 - inline_callback },
1696 - { OPTION_CALLBACK, 0, "thread", &thread, N_("style"),
1693 + inline_callback),
1694 + OPT_CALLBACK_F(0, "thread", &thread, N_("style"),
1695 N_("enable message threading, styles: shallow, deep"),
1698 - PARSE_OPT_OPTARG, thread_callback },
1696 + PARSE_OPT_OPTARG, thread_callback),
1697 OPT_STRING(0, "signature", &signature, N_("signature"),
1698 N_("add a signature")),
1699 OPT_STRING(0, "base", &base_commit, N_("base-commit"),
builtin/ls-files.c
+6 -6
@@ -554,18 +554,18 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
554 N_("show unmerged files in the output")),
555 OPT_BOOL(0, "resolve-undo", &show_resolve_undo,
556 N_("show resolve-undo information")),
557 - { OPTION_CALLBACK, 'x', "exclude", &exclude_list, N_("pattern"),
557 + OPT_CALLBACK_F('x', "exclude", &exclude_list, N_("pattern"),
558 N_("skip files matching pattern"),
559 - PARSE_OPT_NONEG, option_parse_exclude },
560 - { OPTION_CALLBACK, 'X', "exclude-from", &dir, N_("file"),
559 + PARSE_OPT_NONEG, option_parse_exclude),
560 + OPT_CALLBACK_F('X', "exclude-from", &dir, N_("file"),
561 N_("exclude patterns are read from <file>"),
562 - PARSE_OPT_NONEG, option_parse_exclude_from },
562 + PARSE_OPT_NONEG, option_parse_exclude_from),
563 OPT_STRING(0, "exclude-per-directory", &dir.exclude_per_dir, N_("file"),
564 N_("read additional per-directory exclude patterns in <file>")),
565 - { OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
565 + OPT_CALLBACK_F(0, "exclude-standard", &dir, NULL,
566 N_("add the standard git exclusions"),
567 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
568 - option_parse_exclude_standard },
568 + option_parse_exclude_standard),
569 OPT_SET_INT_F(0, "full-name", &prefix_len,
570 N_("make the output relative to the project top directory"),
571 0, PARSE_OPT_NONEG),
builtin/merge.c
+2 -2
@@ -241,9 +241,9 @@ static int option_parse_n(const struct option *opt,
241 }
242
243 static struct option builtin_merge_options[] = {
244 - { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
244 + OPT_CALLBACK_F('n', NULL, NULL, NULL,
245 N_("do not show a diffstat at the end of the merge"),
246 - PARSE_OPT_NOARG, option_parse_n },
246 + PARSE_OPT_NOARG, option_parse_n),
247 OPT_BOOL(0, "stat", &show_diffstat,
248 N_("show a diffstat at the end of the merge")),
249 OPT_BOOL(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
builtin/notes.c
+16 -16
@@ -406,18 +406,18 @@ static int add(int argc, const char **argv, const char *prefix)
406 const struct object_id *note;
407 struct note_data d = { 0, 0, NULL, STRBUF_INIT };
408 struct option options[] = {
409 - { OPTION_CALLBACK, 'm', "message", &d, N_("message"),
409 + OPT_CALLBACK_F('m', "message", &d, N_("message"),
410 N_("note contents as a string"), PARSE_OPT_NONEG,
411 - parse_msg_arg},
412 - { OPTION_CALLBACK, 'F', "file", &d, N_("file"),
411 + parse_msg_arg),
412 + OPT_CALLBACK_F('F', "file", &d, N_("file"),
413 N_("note contents in a file"), PARSE_OPT_NONEG,
414 - parse_file_arg},
415 - { OPTION_CALLBACK, 'c', "reedit-message", &d, N_("object"),
414 + parse_file_arg),
415 + OPT_CALLBACK_F('c', "reedit-message", &d, N_("object"),
416 N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
417 - parse_reedit_arg},
418 - { OPTION_CALLBACK, 'C', "reuse-message", &d, N_("object"),
417 + parse_reedit_arg),
418 + OPT_CALLBACK_F('C', "reuse-message", &d, N_("object"),
419 N_("reuse specified note object"), PARSE_OPT_NONEG,
420 - parse_reuse_arg},
420 + parse_reuse_arg),
421 OPT_BOOL(0, "allow-empty", &allow_empty,
422 N_("allow storing empty note")),
423 OPT__FORCE(&force, N_("replace existing notes"), PARSE_OPT_NOCOMPLETE),
@@ -572,18 +572,18 @@ static int append_edit(int argc, const char **argv, const char *prefix)
572 const char * const *usage;
573 struct note_data d = { 0, 0, NULL, STRBUF_INIT };
574 struct option options[] = {
575 - { OPTION_CALLBACK, 'm', "message", &d, N_("message"),
575 + OPT_CALLBACK_F('m', "message", &d, N_("message"),
576 N_("note contents as a string"), PARSE_OPT_NONEG,
577 - parse_msg_arg},
578 - { OPTION_CALLBACK, 'F', "file", &d, N_("file"),
577 + parse_msg_arg),
578 + OPT_CALLBACK_F('F', "file", &d, N_("file"),
579 N_("note contents in a file"), PARSE_OPT_NONEG,
580 - parse_file_arg},
581 - { OPTION_CALLBACK, 'c', "reedit-message", &d, N_("object"),
580 + parse_file_arg),
581 + OPT_CALLBACK_F('c', "reedit-message", &d, N_("object"),
582 N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
583 - parse_reedit_arg},
584 - { OPTION_CALLBACK, 'C', "reuse-message", &d, N_("object"),
583 + parse_reedit_arg),
584 + OPT_CALLBACK_F('C', "reuse-message", &d, N_("object"),
585 N_("reuse specified note object"), PARSE_OPT_NONEG,
586 - parse_reuse_arg},
586 + parse_reuse_arg),
587 OPT_BOOL(0, "allow-empty", &allow_empty,
588 N_("allow storing empty note")),
589 OPT_END()
builtin/pack-objects.c
+6 -6
@@ -3380,9 +3380,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3380 OPT_BOOL(0, "all-progress-implied",
3381 &all_progress_implied,
3382 N_("similar to --all-progress when progress meter is shown")),
3383 - { OPTION_CALLBACK, 0, "index-version", NULL, N_("<version>[,<offset>]"),
3383 + OPT_CALLBACK_F(0, "index-version", NULL, N_("<version>[,<offset>]"),
3384 N_("write the pack index file in the specified idx format version"),
3385 - PARSE_OPT_NONEG, option_parse_index_version },
3385 + PARSE_OPT_NONEG, option_parse_index_version),
3386 OPT_MAGNITUDE(0, "max-pack-size", &pack_size_limit,
3387 N_("maximum size of each output pack file")),
3388 OPT_BOOL(0, "local", &local,
@@ -3427,9 +3427,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3427 N_("keep unreachable objects")),
3428 OPT_BOOL(0, "pack-loose-unreachable", &pack_loose_unreachable,
3429 N_("pack loose unreachable objects")),
3430 - { OPTION_CALLBACK, 0, "unpack-unreachable", NULL, N_("time"),
3430 + OPT_CALLBACK_F(0, "unpack-unreachable", NULL, N_("time"),
3431 N_("unpack unreachable objects newer than <time>"),
3432 - PARSE_OPT_OPTARG, option_parse_unpack_unreachable },
3432 + PARSE_OPT_OPTARG, option_parse_unpack_unreachable),
3433 OPT_BOOL(0, "sparse", &sparse,
3434 N_("use the sparse reachability algorithm")),
3435 OPT_BOOL(0, "thin", &thin,
@@ -3454,9 +3454,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3454 N_("write a bitmap index if possible"),
3455 WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN),
3456 OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
3457 - { OPTION_CALLBACK, 0, "missing", NULL, N_("action"),
3457 + OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
3458 N_("handling for missing objects"), PARSE_OPT_NONEG,
3459 - option_parse_missing_action },
3459 + option_parse_missing_action),
3460 OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
3461 N_("do not pack objects in promisor packfiles")),
3462 OPT_BOOL(0, "delta-islands", &use_delta_islands,
builtin/pull.c
+4 -4
@@ -118,17 +118,17 @@ static struct option pull_options[] = {
118 OPT_PASSTHRU(0, "progress", &opt_progress, NULL,
119 N_("force progress reporting"),
120 PARSE_OPT_NOARG),
121 - { OPTION_CALLBACK, 0, "recurse-submodules",
121 + OPT_CALLBACK_F(0, "recurse-submodules",
122 &recurse_submodules, N_("on-demand"),
123 N_("control for recursive fetching of submodules"),
124 - PARSE_OPT_OPTARG, option_fetch_parse_recurse_submodules },
124 + PARSE_OPT_OPTARG, option_fetch_parse_recurse_submodules),
125
126 /* Options passed to git-merge or git-rebase */
127 OPT_GROUP(N_("Options related to merging")),
128 - { OPTION_CALLBACK, 'r', "rebase", &opt_rebase,
128 + OPT_CALLBACK_F('r', "rebase", &opt_rebase,
129 "(false|true|merges|preserve|interactive)",
130 N_("incorporate changes by rebasing rather than merging"),
131 - PARSE_OPT_OPTARG, parse_opt_rebase },
131 + PARSE_OPT_OPTARG, parse_opt_rebase),
132 OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,
133 N_("do not show a diffstat at the end of the merge"),
134 PARSE_OPT_NOARG | PARSE_OPT_NONEG),
builtin/push.c
+5 -7
@@ -548,10 +548,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
548 OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN),
549 OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN),
550 OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE),
551 - { OPTION_CALLBACK,
552 - 0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
553 - N_("require old value of ref to be at this value"),
554 - PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option },
551 + OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
552 + N_("require old value of ref to be at this value"),
553 + PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option),
554 { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
555 N_("control recursive pushing of submodules"),
556 PARSE_OPT_OPTARG, option_parse_recurse_submodules },
@@ -566,9 +565,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
565 OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK),
566 OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
567 TRANSPORT_PUSH_FOLLOW_TAGS),
569 - { OPTION_CALLBACK,
570 - 0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"),
571 - PARSE_OPT_OPTARG, option_parse_push_signed },
568 + OPT_CALLBACK_F(0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"),
569 + PARSE_OPT_OPTARG, option_parse_push_signed),
570 OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
571 OPT_STRING_LIST('o', "push-option", &push_options_cmdline, N_("server-specific"), N_("option to transmit")),
572 OPT_SET_INT('4', "ipv4", &family, N_("use IPv4 addresses only"),
builtin/read-tree.c
+6 -6
@@ -120,9 +120,9 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
120 int prefix_set = 0;
121 struct lock_file lock_file = LOCK_INIT;
122 const struct option read_tree_options[] = {
123 - { OPTION_CALLBACK, 0, "index-output", NULL, N_("file"),
123 + OPT_CALLBACK_F(0, "index-output", NULL, N_("file"),
124 N_("write resulting index to <file>"),
125 - PARSE_OPT_NONEG, index_output_cb },
125 + PARSE_OPT_NONEG, index_output_cb),
126 OPT_BOOL(0, "empty", &read_empty,
127 N_("only empty the index")),
128 OPT__VERBOSE(&opts.verbose_update, N_("be verbose")),
@@ -140,10 +140,10 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
140 PARSE_OPT_NONEG },
141 OPT_BOOL('u', NULL, &opts.update,
142 N_("update working tree with merge result")),
143 - { OPTION_CALLBACK, 0, "exclude-per-directory", &opts,
143 + OPT_CALLBACK_F(0, "exclude-per-directory", &opts,
144 N_("gitignore"),
145 N_("allow explicitly ignored files to be overwritten"),
146 - PARSE_OPT_NONEG, exclude_per_directory_cb },
146 + PARSE_OPT_NONEG, exclude_per_directory_cb),
147 OPT_BOOL('i', NULL, &opts.index_only,
148 N_("don't check the working tree after merging")),
149 OPT__DRY_RUN(&opts.dry_run, N_("don't update the index or the work tree")),
@@ -151,9 +151,9 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
151 N_("skip applying sparse checkout filter")),
152 OPT_BOOL(0, "debug-unpack", &opts.debug_unpack,
153 N_("debug unpack-trees")),
154 - { OPTION_CALLBACK, 0, "recurse-submodules", NULL,
154 + OPT_CALLBACK_F(0, "recurse-submodules", NULL,
155 "checkout", "control recursive updating of submodules",
156 - PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater },
156 + PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
157 OPT__QUIET(&opts.quiet, N_("suppress feedback messages")),
158 OPT_END()
159 };
builtin/rebase.c
+10 -10
@@ -474,10 +474,10 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
474 struct option options[] = {
475 OPT_NEGBIT(0, "ff", &opts.flags, N_("allow fast-forward"),
476 REBASE_FORCE),
477 - { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL,
477 + OPT_CALLBACK_F('k', "keep-empty", &options, NULL,
478 N_("keep commits which start empty"),
479 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN,
480 - parse_opt_keep_empty },
480 + parse_opt_keep_empty),
481 OPT_BOOL_F(0, "allow-empty-message", &opts.allow_empty_message,
482 N_("allow commits with empty messages"),
483 PARSE_OPT_HIDDEN),
@@ -1532,18 +1532,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1532 OPT_CMDMODE(0, "show-current-patch", &action,
1533 N_("show the patch file being applied or merged"),
1534 ACTION_SHOW_CURRENT_PATCH),
1535 - { OPTION_CALLBACK, 0, "apply", &options, NULL,
1535 + OPT_CALLBACK_F(0, "apply", &options, NULL,
1536 N_("use apply strategies to rebase"),
1537 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1538 - parse_opt_am },
1539 - { OPTION_CALLBACK, 'm', "merge", &options, NULL,
1538 + parse_opt_am),
1539 + OPT_CALLBACK_F('m', "merge", &options, NULL,
1540 N_("use merging strategies to rebase"),
1541 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1542 - parse_opt_merge },
1543 - { OPTION_CALLBACK, 'i', "interactive", &options, NULL,
1542 + parse_opt_merge),
1543 + OPT_CALLBACK_F('i', "interactive", &options, NULL,
1544 N_("let the user edit the list of commits to rebase"),
1545 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1546 - parse_opt_interactive },
1546 + parse_opt_interactive),
1547 OPT_SET_INT_F('p', "preserve-merges", &options.type,
1548 N_("(DEPRECATED) try to recreate merges instead of "
1549 "ignoring them"),
@@ -1552,10 +1552,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1552 OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
1553 N_("how to handle commits that become empty"),
1554 PARSE_OPT_NONEG, parse_opt_empty),
1555 - { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL,
1555 + OPT_CALLBACK_F('k', "keep-empty", &options, NULL,
1556 N_("keep commits which start empty"),
1557 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN,
1558 - parse_opt_keep_empty },
1558 + parse_opt_keep_empty),
1559 OPT_BOOL(0, "autosquash", &options.autosquash,
1560 N_("move commits that begin with "
1561 "squash!/fixup! under -i")),
builtin/remote.c
+2 -2
@@ -170,9 +170,9 @@ static int add(int argc, const char **argv)
170 OPT_STRING_LIST('t', "track", &track, N_("branch"),
171 N_("branch(es) to track")),
172 OPT_STRING('m', "master", &master, N_("branch"), N_("master branch")),
173 - { OPTION_CALLBACK, 0, "mirror", &mirror, "(push|fetch)",
173 + OPT_CALLBACK_F(0, "mirror", &mirror, "(push|fetch)",
174 N_("set up remote as a mirror to push to or fetch from"),
175 - PARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt },
175 + PARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt),
176 OPT_END()
177 };
178
builtin/reset.c
+2 -2
@@ -302,9 +302,9 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
302 N_("reset HEAD, index and working tree"), MERGE),
303 OPT_SET_INT(0, "keep", &reset_type,
304 N_("reset HEAD but keep local changes"), KEEP),
305 - { OPTION_CALLBACK, 0, "recurse-submodules", NULL,
305 + OPT_CALLBACK_F(0, "recurse-submodules", NULL,
306 "reset", "control recursive updating of submodules",
307 - PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater },
307 + PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
308 OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")),
309 OPT_BOOL('N', "intent-to-add", &intent_to_add,
310 N_("record only the fact that removed paths will be added later")),
builtin/send-pack.c
+4 -6
@@ -165,9 +165,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
165 OPT_BOOL('n' , "dry-run", &dry_run, N_("dry run")),
166 OPT_BOOL(0, "mirror", &send_mirror, N_("mirror all refs")),
167 OPT_BOOL('f', "force", &force_update, N_("force updates")),
168 - { OPTION_CALLBACK,
169 - 0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"),
170 - PARSE_OPT_OPTARG, option_parse_push_signed },
168 + OPT_CALLBACK_F(0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"),
169 + PARSE_OPT_OPTARG, option_parse_push_signed),
170 OPT_STRING_LIST(0, "push-option", &push_options,
171 N_("server-specific"),
172 N_("option to transmit")),
@@ -177,10 +176,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
176 OPT_BOOL(0, "stateless-rpc", &stateless_rpc, N_("use stateless RPC protocol")),
177 OPT_BOOL(0, "stdin", &from_stdin, N_("read refs from stdin")),
178 OPT_BOOL(0, "helper-status", &helper_status, N_("print status from remote helper")),
180 - { OPTION_CALLBACK,
181 - 0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
179 + OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
180 N_("require old value of ref to be at this value"),
183 - PARSE_OPT_OPTARG, parseopt_push_cas_option },
181 + PARSE_OPT_OPTARG, parseopt_push_cas_option),
182 OPT_END()
183 };
184
builtin/shortlog.c
+2 -2
@@ -268,9 +268,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
268 N_("Suppress commit descriptions, only provides commit count")),
269 OPT_BOOL('e', "email", &log.email,
270 N_("Show the email address of each author")),
271 - { OPTION_CALLBACK, 'w', NULL, &log, N_("<w>[,<i1>[,<i2>]]"),
271 + OPT_CALLBACK_F('w', NULL, &log, N_("<w>[,<i1>[,<i2>]]"),
272 N_("Linewrap output"), PARSE_OPT_OPTARG,
273 - &parse_wrap_args },
273 + &parse_wrap_args),
274 OPT_END(),
275 };
276
builtin/show-branch.c
+2 -2
@@ -671,11 +671,11 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
671 N_("topologically sort, maintaining date order "
672 "where possible"),
673 REV_SORT_BY_COMMIT_DATE),
674 - { OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
674 + OPT_CALLBACK_F('g', "reflog", &reflog_base, N_("<n>[,<base>]"),
675 N_("show <n> most recent ref-log entries starting at "
676 "base"),
677 PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
678 - parse_reflog_param },
678 + parse_reflog_param),
679 OPT_END()
680 };
681
builtin/show-ref.c
+6 -6
@@ -169,15 +169,15 @@ static const struct option show_ref_options[] = {
169 N_("show the HEAD reference, even if it would be filtered out")),
170 OPT_BOOL('d', "dereference", &deref_tags,
171 N_("dereference tags into object IDs")),
172 - { OPTION_CALLBACK, 's', "hash", &abbrev, N_("n"),
173 - N_("only show SHA1 hash using <n> digits"),
174 - PARSE_OPT_OPTARG, &hash_callback },
172 + OPT_CALLBACK_F('s', "hash", &abbrev, N_("n"),
173 + N_("only show SHA1 hash using <n> digits"),
174 + PARSE_OPT_OPTARG, &hash_callback),
175 OPT__ABBREV(&abbrev),
176 OPT__QUIET(&quiet,
177 N_("do not print results to stdout (useful with --verify)")),
178 - { OPTION_CALLBACK, 0, "exclude-existing", &exclude_existing_arg,
179 - N_("pattern"), N_("show refs from stdin that aren't in local repository"),
180 - PARSE_OPT_OPTARG | PARSE_OPT_NONEG, exclude_existing_callback },
178 + OPT_CALLBACK_F(0, "exclude-existing", &exclude_existing_arg,
179 + N_("pattern"), N_("show refs from stdin that aren't in local repository"),
180 + PARSE_OPT_OPTARG | PARSE_OPT_NONEG, exclude_existing_callback),
181 OPT_END()
182 };
183
builtin/tag.c
+2 -2
@@ -410,8 +410,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
410 OPT_GROUP(N_("Tag creation options")),
411 OPT_BOOL('a', "annotate", &annotate,
412 N_("annotated tag, needs a message")),
413 - { OPTION_CALLBACK, 'm', "message", &msg, N_("message"),
414 - N_("tag message"), PARSE_OPT_NONEG, parse_msg_arg },
413 + OPT_CALLBACK_F('m', "message", &msg, N_("message"),
414 + N_("tag message"), PARSE_OPT_NONEG, parse_msg_arg),
415 OPT_FILENAME('F', "file", &msgfile, N_("read message from file")),
416 OPT_BOOL('e', "edit", &edit_flag, N_("force edit of tag message")),
417 OPT_BOOL('s', "sign", &opt.sign, N_("annotated and GPG-signed tag")),
builtin/update-index.c
+8 -8
@@ -985,14 +985,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
985 OPT_BIT(0, "unmerged", &refresh_args.flags,
986 N_("refresh even if index contains unmerged entries"),
987 REFRESH_UNMERGED),
988 - {OPTION_CALLBACK, 0, "refresh", &refresh_args, NULL,
988 + OPT_CALLBACK_F(0, "refresh", &refresh_args, NULL,
989 N_("refresh stat information"),
990 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
991 - refresh_callback},
992 - {OPTION_CALLBACK, 0, "really-refresh", &refresh_args, NULL,
991 + refresh_callback),
992 + OPT_CALLBACK_F(0, "really-refresh", &refresh_args, NULL,
993 N_("like --refresh, but ignore assume-unchanged setting"),
994 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
995 - really_refresh_callback},
995 + really_refresh_callback),
996 {OPTION_LOWLEVEL_CALLBACK, 0, "cacheinfo", NULL,
997 N_("<mode>,<object>,<path>"),
998 N_("add the specified entry to the index"),
@@ -1000,10 +1000,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1000 PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
1001 NULL, 0,
1002 cacheinfo_callback},
1003 - {OPTION_CALLBACK, 0, "chmod", &set_executable_bit, "(+|-)x",
1003 + OPT_CALLBACK_F(0, "chmod", &set_executable_bit, "(+|-)x",
1004 N_("override the executable bit of the listed files"),
1005 PARSE_OPT_NONEG,
1006 - chmod_callback},
1006 + chmod_callback),
1007 {OPTION_SET_INT, 0, "assume-unchanged", &mark_valid_only, NULL,
1008 N_("mark files as \"not changing\""),
1009 PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, MARK_FLAG},
@@ -1045,10 +1045,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1045 REFRESH_IGNORE_MISSING),
1046 OPT_SET_INT(0, "verbose", &verbose,
1047 N_("report actions to standard output"), 1),
1048 - {OPTION_CALLBACK, 0, "clear-resolve-undo", NULL, NULL,
1048 + OPT_CALLBACK_F(0, "clear-resolve-undo", NULL, NULL,
1049 N_("(for porcelains) forget saved unresolved conflicts"),
1050 PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1051 - resolve_undo_clear_callback},
1051 + resolve_undo_clear_callback),
1052 OPT_INTEGER(0, "index-version", &preferred_index_format,
1053 N_("write index in this format")),
1054 OPT_BOOL(0, "split-index", &split_index,
list-objects-filter-options.h
+3 -3
@@ -82,9 +82,9 @@ int opt_parse_list_objects_filter(const struct option *opt,
82 const char *arg, int unset);
83
84 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
85 - { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
86 - N_("object filtering"), 0, \
87 - opt_parse_list_objects_filter }
85 + OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \
86 + N_("object filtering"), \
87 + opt_parse_list_objects_filter)
88
89 /*
90 * Translates abbreviated numbers in the filter's filter_spec into their