Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static void extra_file_info_clear(void *util, const char *str UNUSED)
static int add_file_cb(const struct option *opt, const char *arg, int unset)
{
struct archiver_args *args = opt->value;
const char **basep = (const char **)opt->defval;
const char **basep = (const char **)DEFVAL_TO_PTR(opt->defval);
const char *base = *basep;
char *path;
struct string_list_item *item;
Expand Down Expand Up @@ -657,7 +657,7 @@ static int parse_archive_args(int argc, const char **argv,
.argh = N_("file"),
.help = N_("add untracked file to archive"),
.callback = add_file_cb,
.defval = (intptr_t) &base,
.defval = DEFVAL_PTR(&base),
},
{
.type = OPTION_CALLBACK,
Expand All @@ -666,7 +666,7 @@ static int parse_archive_args(int argc, const char **argv,
.argh = N_("path:content"),
.help = N_("add untracked file to archive"),
.callback = add_file_cb,
.defval = (intptr_t) &base,
.defval = DEFVAL_PTR(&base),
},
OPT_STRING('o', "output", &output, N_("file"),
N_("write the archive to this file")),
Expand Down
6 changes: 3 additions & 3 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
BUG_ON_OPT_NEG(unset);

if (!arg)
*opt_value = opt->defval;
*opt_value = DEFVAL_TO_INT(opt->defval);
else if (!strcmp(arg, "raw"))
*opt_value = RESUME_SHOW_PATCH_RAW;
else if (!strcmp(arg, "diff"))
Expand Down Expand Up @@ -2413,7 +2413,7 @@ int cmd_am(int argc,
.help = N_("show the patch being applied"),
.flags = PARSE_OPT_CMDMODE | PARSE_OPT_OPTARG | PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
.callback = parse_opt_show_current_patch,
.defval = RESUME_SHOW_PATCH_RAW,
.defval = DEFVAL_INT(RESUME_SHOW_PATCH_RAW),
},
OPT_CMDMODE(0, "retry", &resume_mode,
N_("try to apply current patch again"),
Expand All @@ -2435,7 +2435,7 @@ int cmd_am(int argc,
.argh = N_("key-id"),
.help = N_("GPG-sign commits"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
OPT_CALLBACK_F(0, "empty", &state.empty_type, "(stop|drop|keep)",
N_("how to handle empty patches"),
Expand Down
4 changes: 2 additions & 2 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int recurse_submodules_cb(const struct option *opt,
string_list_append((struct string_list *)opt->value, arg);
else
string_list_append((struct string_list *)opt->value,
(const char *)opt->defval);
(const char *)DEFVAL_TO_PTR(opt->defval));

return 0;
}
Expand Down Expand Up @@ -946,7 +946,7 @@ int cmd_clone(int argc,
.help = N_("initialize submodules in the clone"),
.flags = PARSE_OPT_OPTARG,
.callback = recurse_submodules_cb,
.defval = (intptr_t)".",
.defval = DEFVAL_PTR("."),
},
OPT_ALIAS(0, "recursive", "recurse-submodules"),
OPT_INTEGER('j', "jobs", &max_jobs,
Expand Down
2 changes: 1 addition & 1 deletion builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int cmd_commit_tree(int argc,
.argh = N_("key-id"),
.help = N_("GPG sign commit"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
OPT_END()
};
Expand Down
10 changes: 5 additions & 5 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ struct repository *repo UNUSED)
.argh = N_("mode"),
.help = N_("show untracked files, optional modes: all, normal, no. (Default: all)"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t)"all",
.defval = DEFVAL_PTR("all"),
},
{
.type = OPTION_STRING,
Expand All @@ -1580,7 +1580,7 @@ struct repository *repo UNUSED)
.argh = N_("mode"),
.help = N_("show ignored files, optional modes: traditional, matching, no. (Default: traditional)"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t)"traditional",
.defval = DEFVAL_PTR("traditional"),
},
{
.type = OPTION_STRING,
Expand All @@ -1589,7 +1589,7 @@ struct repository *repo UNUSED)
.argh = N_("when"),
.help = N_("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t)"all",
.defval = DEFVAL_PTR("all"),
},
OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
OPT_BOOL(0, "no-renames", &no_renames, N_("do not detect renames")),
Expand Down Expand Up @@ -1735,7 +1735,7 @@ int cmd_commit(int argc,
.argh = N_("key-id"),
.help = N_("GPG sign commit"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
/* end commit message options */

Expand Down Expand Up @@ -1771,7 +1771,7 @@ int cmd_commit(int argc,
.argh = N_("mode"),
.help = N_("show untracked files, optional modes: all, normal, no. (Default: all)"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t)"all",
.defval = DEFVAL_PTR("all"),
},
OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
Expand Down
4 changes: 2 additions & 2 deletions builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct config_display_options {
.help = (h), \
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG, \
.callback = option_parse_type, \
.defval = (i), \
.defval = DEFVAL_INT(i), \
}

static int option_parse_type(const struct option *opt, const char *arg,
Expand All @@ -162,7 +162,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
* To support '--<type>' style flags, begin with new_type equal to
* opt->defval.
*/
new_type = opt->defval;
new_type = DEFVAL_TO_INT(opt->defval);
if (!new_type) {
if (!strcmp(arg, "bool"))
new_type = TYPE_BOOL;
Expand Down
4 changes: 2 additions & 2 deletions builtin/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ int cmd_describe(int argc,
.argh = N_("mark"),
.help = N_("append <mark> on dirty working tree (default: \"-dirty\")"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "-dirty",
.defval = DEFVAL_PTR("-dirty"),
},
{
.type = OPTION_STRING,
Expand All @@ -680,7 +680,7 @@ int cmd_describe(int argc,
.argh = N_("mark"),
.help = N_("append <mark> on broken working tree (default: \"-broken\")"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "-broken",
.defval = DEFVAL_PTR("-broken"),
},
OPT_END(),
};
Expand Down
4 changes: 2 additions & 2 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int cmd_fmt_merge_msg(int argc,
.argh = N_("n"),
.help = N_("populate log with at most <n> entries from shortlog"),
.flags = PARSE_OPT_OPTARG,
.defval = DEFAULT_MERGE_LOG_LEN,
.defval = DEFVAL_INT(DEFAULT_MERGE_LOG_LEN),
},
{
.type = OPTION_INTEGER,
Expand All @@ -38,7 +38,7 @@ int cmd_fmt_merge_msg(int argc,
.argh = N_("n"),
.help = N_("alias for --log (deprecated)"),
.flags = PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN,
.defval = DEFAULT_MERGE_LOG_LEN,
.defval = DEFVAL_INT(DEFAULT_MERGE_LOG_LEN),
},
OPT_STRING('m', "message", &message, N_("text"),
N_("use <text> as start of message")),
Expand Down
2 changes: 1 addition & 1 deletion builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ int cmd_gc(int argc,
.argh = N_("date"),
.help = N_("prune unreferenced objects"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t)prune_expire_arg,
.defval = DEFVAL_PTR(prune_expire_arg),
},
OPT_BOOL(0, "cruft", &cfg.cruft_packs, N_("pack unreferenced objects separately")),
OPT_UNSIGNED(0, "max-cruft-size", &cfg.max_cruft_size,
Expand Down
2 changes: 1 addition & 1 deletion builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ int cmd_grep(int argc,
.argh = N_("pager"),
.help = N_("show matching files in the pager"),
.flags = PARSE_OPT_OPTARG | PARSE_OPT_NOCOMPLETE,
.defval = (intptr_t)default_pager,
.defval = DEFVAL_PTR(default_pager),
},
OPT_BOOL_F(0, "ext-grep", &external_grep_allowed__ignored,
N_("allow calling of grep(1) (ignored by this build)"),
Expand Down
4 changes: 2 additions & 2 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static struct option builtin_merge_options[] = {
.argh = N_("n"),
.help = N_("add (at most <n>) entries from shortlog to merge commit message"),
.flags = PARSE_OPT_OPTARG,
.defval = DEFAULT_MERGE_LOG_LEN,
.defval = DEFVAL_INT(DEFAULT_MERGE_LOG_LEN),
},
OPT_BOOL(0, "squash", &squash,
N_("create a single commit instead of doing a merge")),
Expand Down Expand Up @@ -329,7 +329,7 @@ static struct option builtin_merge_options[] = {
.argh = N_("key-id"),
.help = N_("GPG sign commit"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
OPT_AUTOSTASH(&autostash),
OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
Expand Down
4 changes: 2 additions & 2 deletions builtin/rebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ int cmd_rebase(int argc,
.precision = sizeof(options.flags),
.help = N_("do not show diffstat of what changed upstream"),
.flags = PARSE_OPT_NOARG,
.defval = REBASE_DIFFSTAT,
.defval = DEFVAL_INT(REBASE_DIFFSTAT),
},
OPT_STRVEC(0, "trailer", &options.trailer_args, N_("trailer"),
N_("add custom trailer(s)")),
Expand Down Expand Up @@ -1216,7 +1216,7 @@ int cmd_rebase(int argc,
.argh = N_("key-id"),
.help = N_("GPG-sign commits"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
OPT_AUTOSTASH(&options.autostash),
OPT_STRING_LIST('x', "exec", &options.exec, N_("exec"),
Expand Down
2 changes: 1 addition & 1 deletion builtin/revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
.argh = N_("key-id"),
.help = N_("GPG sign commit"),
.flags = PARSE_OPT_OPTARG,
.defval = (intptr_t) "",
.defval = DEFVAL_PTR(""),
},
OPT_END()
};
Expand Down
2 changes: 1 addition & 1 deletion builtin/show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ int cmd_show_branch(int ac,
.argh = N_("n"),
.help = N_("show <n> more commits after the common ancestor"),
.flags = PARSE_OPT_OPTARG,
.defval = 1,
.defval = DEFVAL_INT(1),
},
OPT_SET_INT(0, "list", &extra, N_("synonym to more=-1"), -1),
OPT_BOOL(0, "no-name", &no_name, N_("suppress naming strings")),
Expand Down
4 changes: 2 additions & 2 deletions builtin/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int cmd_tag(int argc,
.argh = N_("n"),
.help = N_("print <n> lines of each tag message"),
.flags = PARSE_OPT_OPTARG,
.defval = 1,
.defval = DEFVAL_INT(1),
},
OPT_CMDMODE('d', "delete", &cmdmode, N_("delete tags"), 'd'),
OPT_CMDMODE('v', "verify", &cmdmode, N_("verify tags"), 'v'),
Expand Down Expand Up @@ -528,7 +528,7 @@ int cmd_tag(int argc,
.help = N_("print only tags of the object"),
.flags = PARSE_OPT_LASTARG_DEFAULT,
.callback = parse_opt_object_name,
.defval = (intptr_t) "HEAD",
.defval = DEFVAL_PTR("HEAD"),
},
OPT_STRING( 0 , "format", &format.format, N_("format"),
N_("format to use for the output")),
Expand Down
12 changes: 6 additions & 6 deletions builtin/update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_valid_only),
.help = N_("mark files as \"not changing\""),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = MARK_FLAG,
.defval = DEFVAL_INT(MARK_FLAG),
},
{
.type = OPTION_SET_INT,
Expand All @@ -987,7 +987,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_valid_only),
.help = N_("clear assumed-unchanged bit"),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = UNMARK_FLAG,
.defval = DEFVAL_INT(UNMARK_FLAG),
},
{
.type = OPTION_SET_INT,
Expand All @@ -996,7 +996,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_skip_worktree_only),
.help = N_("mark files as \"index-only\""),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = MARK_FLAG,
.defval = DEFVAL_INT(MARK_FLAG),
},
{
.type = OPTION_SET_INT,
Expand All @@ -1005,7 +1005,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_skip_worktree_only),
.help = N_("clear skip-worktree bit"),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = UNMARK_FLAG,
.defval = DEFVAL_INT(UNMARK_FLAG),
},
OPT_BOOL(0, "ignore-skip-worktree-entries", &ignore_skip_worktree_entries,
N_("do not touch index-only entries")),
Expand Down Expand Up @@ -1080,7 +1080,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_fsmonitor_only),
.help = N_("mark files as fsmonitor valid"),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = MARK_FLAG,
.defval = DEFVAL_INT(MARK_FLAG),
},
{
.type = OPTION_SET_INT,
Expand All @@ -1089,7 +1089,7 @@ int cmd_update_index(int argc,
.precision = sizeof(mark_fsmonitor_only),
.help = N_("clear fsmonitor valid bit"),
.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG,
.defval = UNMARK_FLAG,
.defval = DEFVAL_INT(UNMARK_FLAG),
},
OPT_END()
};
Expand Down
2 changes: 1 addition & 1 deletion builtin/write-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int cmd_write_tree(int argc,
.precision = sizeof(flags),
.help = N_("only useful for debugging"),
.flags = PARSE_OPT_HIDDEN | PARSE_OPT_NOARG,
.defval = WRITE_TREE_IGNORE_CACHE_TREE,
.defval = DEFVAL_INT(WRITE_TREE_IGNORE_CACHE_TREE),
},
OPT_END()
};
Expand Down
Loading