Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
fetch: convert get_ref_map to take a struct refspec
author
Brandon Williams
<bmwill@google.com>
Wed, 16 May 2018 22:58:08 +0000
(15:58 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 17 May 2018 21:19:43 +0000
(06:19 +0900)
Convert 'get_ref_map()' to take a 'struct refspec' as a parameter
instead of a list of 'struct refspec_item'.
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:
65a1301
)
diff --git
a/builtin/fetch.c
b/builtin/fetch.c
index ec54b1dfe147ce672d5ad18183179f02dac21726..836eb7545c504b37f12c883e6a8267781022725e 100644
(file)
--- a/
builtin/fetch.c
+++ b/
builtin/fetch.c
@@
-337,7
+337,7
@@
static void find_non_local_tags(struct transport *transport,
}
static struct ref *get_ref_map(struct transport *transport,
}
static struct ref *get_ref_map(struct transport *transport,
- struct refspec
_item *refspecs, int refspec_count
,
+ struct refspec
*rs
,
int tags, int *autotags)
{
int i;
int tags, int *autotags)
{
int i;
@@
-351,15
+351,16
@@
static struct ref *get_ref_map(struct transport *transport,
const struct ref *remote_refs;
const struct ref *remote_refs;
- for (i = 0; i < refspec_count; i++) {
- if (!refspecs[i].exact_sha1) {
- const char *glob = strchr(refspecs[i].src, '*');
+ for (i = 0; i < rs->nr; i++) {
+ const struct refspec_item *item = &rs->items[i];
+ if (!item->exact_sha1) {
+ const char *glob = strchr(item->src, '*');
if (glob)
argv_array_pushf(&ref_prefixes, "%.*s",
if (glob)
argv_array_pushf(&ref_prefixes, "%.*s",
- (int)(glob -
refspecs[i].
src),
-
refspecs[i].
src);
+ (int)(glob -
item->
src),
+
item->
src);
else
else
- expand_ref_prefix(&ref_prefixes,
refspecs[i].
src);
+ expand_ref_prefix(&ref_prefixes,
item->
src);
}
}
}
}
@@
-367,13
+368,12
@@
static struct ref *get_ref_map(struct transport *transport,
argv_array_clear(&ref_prefixes);
argv_array_clear(&ref_prefixes);
- if (refspec_count) {
- struct refspec_item *fetch_refspec;
- int fetch_refspec_nr;
+ if (rs->nr) {
+ struct refspec *fetch_refspec;
- for (i = 0; i < r
efspec_count
; i++) {
- get_fetch_map(remote_refs, &r
efspec
s[i], &tail, 0);
- if (r
efspecs[i].dst && refspec
s[i].dst[0])
+ for (i = 0; i < r
s->nr
; i++) {
+ get_fetch_map(remote_refs, &r
s->item
s[i], &tail, 0);
+ if (r
s->items[i].dst && rs->item
s[i].dst[0])
*autotags = 1;
}
/* Merge everything on the command line (but not --tags) */
*autotags = 1;
}
/* Merge everything on the command line (but not --tags) */
@@
-400,16
+400,13
@@
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.nr) {
- fetch_refspec = refmap.items;
- fetch_refspec_nr = refmap.nr;
- } else {
- fetch_refspec = transport->remote->fetch.items;
- fetch_refspec_nr = transport->remote->fetch.nr;
- }
+ if (refmap.nr)
+ fetch_refspec = &refmap;
+ else
+ fetch_refspec = &transport->remote->fetch;
- 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
->items
[i], &oref_tail, 1);
} else if (refmap.nr) {
die("--refmap option is only meaningful with command-line refspec(s).");
} else {
} else if (refmap.nr) {
die("--refmap option is only meaningful with command-line refspec(s).");
} else {
@@
-1136,7
+1133,7
@@
static int do_fetch(struct transport *transport,
goto cleanup;
}
goto cleanup;
}
- ref_map = get_ref_map(transport, rs
->items, rs->nr
, tags, &autotags);
+ ref_map = get_ref_map(transport, rs, tags, &autotags);
if (!update_head_ok)
check_not_current_branch(ref_map);
if (!update_head_ok)
check_not_current_branch(ref_map);