Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> --- builtin/fetch.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 9a04512..fcc06a4 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -30,8 +30,7 @@ enum { TAGS_SET = 2 }; -static int fetch_prune_config = -1; /* unspecified */ -static int prune = -1; /* unspecified */ +static struct prune_option prune_option = PRUNE_OPTION_INIT; #define PRUNE_BY_DEFAULT 0 /* do we prune by default? */ static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity; @@ -59,15 +58,6 @@ static int option_parse_recurse_submodules(const struct option *opt, return 0; } -static int git_fetch_config(const char *k, const char *v, void *cb) -{ - if (!strcmp(k, "fetch.prune")) { - fetch_prune_config = git_config_bool(k, v); - return 0; - } - return 0; -} - static struct option builtin_fetch_options[] = { OPT__VERBOSITY(&verbosity), OPT_BOOL(0, "all", &all, @@ -83,8 +73,9 @@ static struct option builtin_fetch_options[] = { N_("fetch all tags and associated objects"), TAGS_SET), OPT_SET_INT('n', NULL, &tags, N_("do not fetch all tags (--no-tags)"), TAGS_UNSET), - OPT_BOOL('p', "prune", &prune, - N_("prune remote-tracking branches no longer on remote")), + { OPTION_CALLBACK, 'p', "prune", &prune_option, N_("pattern"), + N_("prune remote-tracking branches no longer on remote"), + PARSE_OPT_NOARG, prune_option_parse }, { OPTION_CALLBACK, 0, "recurse-submodules", NULL, N_("on-demand"), N_("control recursive fetching of submodules"), PARSE_OPT_OPTARG, option_parse_recurse_submodules }, @@ -848,7 +839,7 @@ static int do_fetch(struct transport *transport, retcode = 1; goto cleanup; } - if (prune) { + if (prune_option.prune) { /* * We only prune based on refspecs specified * explicitly (via command line or configuration); we @@ -935,8 +926,7 @@ static void add_options_to_argv(struct argv_array *argv) { if (dry_run) argv_array_push(argv, "--dry-run"); - if (prune != -1) - argv_array_push(argv, prune ? "--prune" : "--no-prune"); + argv_push_prune_option(argv, &prune_option); if (update_head_ok) argv_array_push(argv, "--update-head-ok"); if (force) @@ -1002,17 +992,9 @@ static int fetch_one(struct remote *remote, int argc, const char **argv) die(_("No remote repository specified. Please, specify either a URL or a\n" "remote name from which new revisions should be fetched.")); - gtransport = prepare_transport(remote); + prune_option_fill(remote, &prune_option, PRUNE_BY_DEFAULT); - if (prune < 0) { - /* no command line request */ - if (0 <= gtransport->remote->prune) - prune = gtransport->remote->prune; - else if (0 <= fetch_prune_config) - prune = fetch_prune_config; - else - prune = PRUNE_BY_DEFAULT; - } + gtransport = prepare_transport(remote); if (argc > 0) { int j = 0; @@ -1063,8 +1045,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) for (i = 1; i < argc; i++) strbuf_addf(&default_rla, " %s", argv[i]); - git_config(git_fetch_config, NULL); - argc = parse_options(argc, argv, prefix, builtin_fetch_options, builtin_fetch_usage, 0); -- 1.8.4.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html