fetch: convert refmap to use struct refspec
Convert the refmap in builtin/fetch.c to be stored in a 'struct refspec'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
May 16, 2018 at 15:58 UTC
e4cffacc8047d675983ecdbc7c7c284276514fe1
1 file changed
+7
-10
builtin/fetch.c
+7
-10
@@ -60,8 +60,7 @@ static const char *submodule_prefix = "";
60
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
61
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
62
static int shown_url = 0;
63
-static int refmap_alloc, refmap_nr;
64
-static const char **refmap_array;
63
+static struct refspec refmap = REFSPEC_INIT_FETCH;
64
static struct list_objects_filter_options filter_options;
65
66
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -108,14 +107,12 @@ static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
107
108
static int parse_refmap_arg(const struct option *opt, const char *arg, int unset)
109
{
111
- ALLOC_GROW(refmap_array, refmap_nr + 1, refmap_alloc);
112
-
110
/*
111
* "git fetch --refmap='' origin foo"
112
* can be used to tell the command not to store anywhere
113
*/
117
- if (*arg)
118
- refmap_array[refmap_nr++] = arg;
114
+ refspec_append(&refmap, arg);
115
+
116
return 0;
117
}
118
@@ -403,9 +400,9 @@ static struct ref *get_ref_map(struct transport *transport,
400
* by ref_remove_duplicates() in favor of one of these
401
* opportunistic entries with FETCH_HEAD_IGNORE.
402
*/
406
- if (refmap_array) {
407
- fetch_refspec = parse_fetch_refspec(refmap_nr, refmap_array);
408
- fetch_refspec_nr = refmap_nr;
403
+ if (refmap.nr) {
404
+ fetch_refspec = refmap.items;
405
+ fetch_refspec_nr = refmap.nr;
406
} else {
407
fetch_refspec = transport->remote->fetch.items;
408
fetch_refspec_nr = transport->remote->fetch.nr;
@@ -413,7 +410,7 @@ static struct ref *get_ref_map(struct transport *transport,
410
411
for (i = 0; i < fetch_refspec_nr; i++)
412
get_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);
416
- } else if (refmap_array) {
413
+ } else if (refmap.nr) {
414
die("--refmap option is only meaningful with command-line refspec(s).");
415
} else {
416
/* Use the defaults */