30
TAGS_SET = 2
31
};
32
33
-static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
33
+static int fetch_prune_config = -1; /* unspecified */
34
+static int prune = -1; /* unspecified */
35
+#define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
36
+
37
+static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity;
38
static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
39
static int tags = TAGS_DEFAULT, unshallow;
40
static const char *depth;
58
return 0;
59
}
60
61
+static int git_fetch_config(const char *k, const char *v, void *cb)
62
+{
63
+ if (!strcmp(k, "fetch.prune")) {
64
+ fetch_prune_config = git_config_bool(k, v);
65
+ return 0;
66
+ }
67
+ return 0;
68
+}
69
+
70
static struct option builtin_fetch_options[] = {
71
OPT__VERBOSITY(&verbosity),
72
OPT_BOOLEAN(0, "all", &all,
82
N_("fetch all tags and associated objects"), TAGS_SET),
83
OPT_SET_INT('n', NULL, &tags,
84
N_("do not fetch all tags (--no-tags)"), TAGS_UNSET),
72
- OPT_BOOLEAN('p', "prune", &prune,
73
- N_("prune remote-tracking branches no longer on remote")),
85
+ OPT_BOOL('p', "prune", &prune,
86
+ N_("prune remote-tracking branches no longer on remote")),
87
{ OPTION_CALLBACK, 0, "recurse-submodules", NULL, N_("on-demand"),
88
N_("control recursive fetching of submodules"),
89
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
752
return 1;
753
}
754
if (prune) {
742
- /* If --tags was specified, pretend the user gave us the canonical tags refspec */
755
+ /*
756
+ * If --tags was specified, pretend that the user gave us
757
+ * the canonical tags refspec
758
+ */
759
if (tags == TAGS_SET) {
760
const char *tags_str = "refs/tags/*:refs/tags/*";
761
struct refspec *tags_refspec, *refspec;
864
{
865
if (dry_run)
866
argv_array_push(argv, "--dry-run");
851
- if (prune)
867
+ if (prune > 0)
868
argv_array_push(argv, "--prune");
869
if (update_head_ok)
870
argv_array_push(argv, "--update-head-ok");
932
"remote name from which new revisions should be fetched."));
933
934
transport = transport_get(remote, NULL);
935
+
936
+ if (prune < 0) {
937
+ /* no command line request */
938
+ if (0 <= transport->remote->prune)
939
+ prune = transport->remote->prune;
940
+ else if (0 <= fetch_prune_config)
941
+ prune = fetch_prune_config;
942
+ else
943
+ prune = PRUNE_BY_DEFAULT;
944
+ }
945
+
946
transport_set_verbosity(transport, verbosity, progress);
947
if (upload_pack)
948
set_option(TRANS_OPT_UPLOADPACK, upload_pack);
1000
for (i = 1; i < argc; i++)
1001
strbuf_addf(&default_rla, " %s", argv[i]);
1002
1003
+ git_config(git_fetch_config, NULL);
1004
+
1005
argc = parse_options(argc, argv, prefix,
1006
builtin_fetch_options, builtin_fetch_usage, 0);
1007