remote: convert get_ref_match to take a struct refspec
Convert 'get_ref_match()' 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>maint
parent
86baf82521
commit
f3acb8309f
26
remote.c
26
remote.c
|
@ -1082,27 +1082,29 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
|
||||||
return errs;
|
return errs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struct ref *ref,
|
static char *get_ref_match(const struct refspec *rs, const struct ref *ref,
|
||||||
int send_mirror, int direction, const struct refspec_item **ret_pat)
|
int send_mirror, int direction,
|
||||||
|
const struct refspec_item **ret_pat)
|
||||||
{
|
{
|
||||||
const struct refspec_item *pat;
|
const struct refspec_item *pat;
|
||||||
char *name;
|
char *name;
|
||||||
int i;
|
int i;
|
||||||
int matching_refs = -1;
|
int matching_refs = -1;
|
||||||
for (i = 0; i < rs_nr; i++) {
|
for (i = 0; i < rs->nr; i++) {
|
||||||
if (rs[i].matching &&
|
const struct refspec_item *item = &rs->items[i];
|
||||||
(matching_refs == -1 || rs[i].force)) {
|
if (item->matching &&
|
||||||
|
(matching_refs == -1 || item->force)) {
|
||||||
matching_refs = i;
|
matching_refs = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs[i].pattern) {
|
if (item->pattern) {
|
||||||
const char *dst_side = rs[i].dst ? rs[i].dst : rs[i].src;
|
const char *dst_side = item->dst ? item->dst : item->src;
|
||||||
int match;
|
int match;
|
||||||
if (direction == FROM_SRC)
|
if (direction == FROM_SRC)
|
||||||
match = match_name_with_pattern(rs[i].src, ref->name, dst_side, &name);
|
match = match_name_with_pattern(item->src, ref->name, dst_side, &name);
|
||||||
else
|
else
|
||||||
match = match_name_with_pattern(dst_side, ref->name, rs[i].src, &name);
|
match = match_name_with_pattern(dst_side, ref->name, item->src, &name);
|
||||||
if (match) {
|
if (match) {
|
||||||
matching_refs = i;
|
matching_refs = i;
|
||||||
break;
|
break;
|
||||||
|
@ -1112,7 +1114,7 @@ static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struc
|
||||||
if (matching_refs == -1)
|
if (matching_refs == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pat = rs + matching_refs;
|
pat = &rs->items[matching_refs];
|
||||||
if (pat->matching) {
|
if (pat->matching) {
|
||||||
/*
|
/*
|
||||||
* "matching refs"; traditionally we pushed everything
|
* "matching refs"; traditionally we pushed everything
|
||||||
|
@ -1309,7 +1311,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
|
||||||
const struct refspec_item *pat = NULL;
|
const struct refspec_item *pat = NULL;
|
||||||
char *dst_name;
|
char *dst_name;
|
||||||
|
|
||||||
dst_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_SRC, &pat);
|
dst_name = get_ref_match(&rs, ref, send_mirror, FROM_SRC, &pat);
|
||||||
if (!dst_name)
|
if (!dst_name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1358,7 +1360,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
|
||||||
/* We're already sending something to this ref. */
|
/* We're already sending something to this ref. */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
src_name = get_ref_match(rs.items, rs.nr, ref, send_mirror, FROM_DST, NULL);
|
src_name = get_ref_match(&rs, ref, send_mirror, FROM_DST, NULL);
|
||||||
if (src_name) {
|
if (src_name) {
|
||||||
if (!src_ref_index.nr)
|
if (!src_ref_index.nr)
|
||||||
prepare_ref_index(&src_ref_index, src);
|
prepare_ref_index(&src_ref_index, src);
|
||||||
|
|
Loading…
Reference in New Issue