Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
fetch: convert refmap to use struct refspec
author
Brandon Williams
<bmwill@google.com>
Wed, 16 May 2018 22:58:05 +0000
(15:58 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 17 May 2018 21:19:43 +0000
(06:19 +0900)
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>
builtin/fetch.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
d7c8e30
)
diff --git
a/builtin/fetch.c
b/builtin/fetch.c
index 18704c6cd6c58add7d05a7d134efa3d1dfc86d81..6b909cd5bf2524301ccf919a0de073bee6cd4dab 100644
(file)
--- a/
builtin/fetch.c
+++ b/
builtin/fetch.c
@@
-60,8
+60,7
@@
static const char *submodule_prefix = "";
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
static int shown_url = 0;
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
static int shown_url = 0;
-static int refmap_alloc, refmap_nr;
-static const char **refmap_array;
+static struct refspec refmap = REFSPEC_INIT_FETCH;
static struct list_objects_filter_options filter_options;
static int git_fetch_config(const char *k, const char *v, void *cb)
static struct list_objects_filter_options filter_options;
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)
static int parse_refmap_arg(const struct option *opt, const char *arg, int unset)
{
static int parse_refmap_arg(const struct option *opt, const char *arg, int unset)
{
- ALLOC_GROW(refmap_array, refmap_nr + 1, refmap_alloc);
-
/*
* "git fetch --refmap='' origin foo"
* can be used to tell the command not to store anywhere
*/
/*
* "git fetch --refmap='' origin foo"
* can be used to tell the command not to store anywhere
*/
- if (*arg)
- refmap_array[refmap_nr++] = arg;
+ refspec_append(&refmap, arg);
+
return 0;
}
return 0;
}
@@
-403,9
+400,9
@@
static struct ref *get_ref_map(struct transport *transport,
* by ref_remove_duplicates() in favor of one of these
* opportunistic entries with FETCH_HEAD_IGNORE.
*/
* by ref_remove_duplicates() in favor of one of these
* opportunistic entries with FETCH_HEAD_IGNORE.
*/
- if (refmap
_array
) {
- fetch_refspec =
parse_fetch_refspec(refmap_nr, refmap_array)
;
- fetch_refspec_nr = refmap
_
nr;
+ if (refmap
.nr
) {
+ fetch_refspec =
refmap.items
;
+ fetch_refspec_nr = refmap
.
nr;
} else {
fetch_refspec = transport->remote->fetch.items;
fetch_refspec_nr = transport->remote->fetch.nr;
} else {
fetch_refspec = transport->remote->fetch.items;
fetch_refspec_nr = transport->remote->fetch.nr;
@@
-413,7
+410,7
@@
static struct ref *get_ref_map(struct transport *transport,
for (i = 0; i < fetch_refspec_nr; i++)
get_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);
for (i = 0; i < fetch_refspec_nr; i++)
get_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);
- } else if (refmap
_array
) {
+ } else if (refmap
.nr
) {
die("--refmap option is only meaningful with command-line refspec(s).");
} else {
/* Use the defaults */
die("--refmap option is only meaningful with command-line refspec(s).");
} else {
/* Use the defaults */