remote: convert match_push_refs to take a struct refspec
Convert 'match_push_refs()' to take a 'struct refspec' as a parameter instead of an array of 'const char *'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
38490dd416
commit
5c7ec8462d
@ -387,8 +387,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
|
|||||||
local_refs = get_local_heads();
|
local_refs = get_local_heads();
|
||||||
push_map = copy_ref_list(remote_refs);
|
push_map = copy_ref_list(remote_refs);
|
||||||
|
|
||||||
match_push_refs(local_refs, &push_map, remote->push.raw_nr,
|
match_push_refs(local_refs, &push_map, &remote->push, MATCH_REFS_NONE);
|
||||||
remote->push.raw, MATCH_REFS_NONE);
|
|
||||||
|
|
||||||
states->push.strdup_strings = 1;
|
states->push.strdup_strings = 1;
|
||||||
for (ref = push_map; ref; ref = ref->next) {
|
for (ref = push_map; ref; ref = ref->next) {
|
||||||
|
@ -275,7 +275,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
|
|||||||
flags |= MATCH_REFS_MIRROR;
|
flags |= MATCH_REFS_MIRROR;
|
||||||
|
|
||||||
/* match them up */
|
/* match them up */
|
||||||
if (match_push_refs(local_refs, &remote_refs, rs.raw_nr, rs.raw, flags))
|
if (match_push_refs(local_refs, &remote_refs, &rs, flags))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!is_empty_cas(&cas))
|
if (!is_empty_cas(&cas))
|
||||||
|
@ -1823,8 +1823,7 @@ int cmd_main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* match them up */
|
/* match them up */
|
||||||
if (match_push_refs(local_refs, &remote_refs,
|
if (match_push_refs(local_refs, &remote_refs, &rs, push_all)) {
|
||||||
rs.raw_nr, rs.raw, push_all)) {
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
21
remote.c
21
remote.c
@ -1285,23 +1285,20 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
|
|||||||
* dst (e.g. pushing to a new branch, done in match_explicit_refs).
|
* dst (e.g. pushing to a new branch, done in match_explicit_refs).
|
||||||
*/
|
*/
|
||||||
int match_push_refs(struct ref *src, struct ref **dst,
|
int match_push_refs(struct ref *src, struct ref **dst,
|
||||||
int nr_refspec, const char **refspec, int flags)
|
struct refspec *rs, int flags)
|
||||||
{
|
{
|
||||||
struct refspec rs = REFSPEC_INIT_PUSH;
|
|
||||||
int send_all = flags & MATCH_REFS_ALL;
|
int send_all = flags & MATCH_REFS_ALL;
|
||||||
int send_mirror = flags & MATCH_REFS_MIRROR;
|
int send_mirror = flags & MATCH_REFS_MIRROR;
|
||||||
int send_prune = flags & MATCH_REFS_PRUNE;
|
int send_prune = flags & MATCH_REFS_PRUNE;
|
||||||
int errs;
|
int errs;
|
||||||
static const char *default_refspec[] = { ":", NULL };
|
|
||||||
struct ref *ref, **dst_tail = tail_ref(dst);
|
struct ref *ref, **dst_tail = tail_ref(dst);
|
||||||
struct string_list dst_ref_index = STRING_LIST_INIT_NODUP;
|
struct string_list dst_ref_index = STRING_LIST_INIT_NODUP;
|
||||||
|
|
||||||
if (!nr_refspec) {
|
/* If no refspec is provided, use the default ":" */
|
||||||
nr_refspec = 1;
|
if (!rs->nr)
|
||||||
refspec = default_refspec;
|
refspec_append(rs, ":");
|
||||||
}
|
|
||||||
refspec_appendn(&rs, refspec, nr_refspec);
|
errs = match_explicit_refs(src, *dst, &dst_tail, rs);
|
||||||
errs = match_explicit_refs(src, *dst, &dst_tail, &rs);
|
|
||||||
|
|
||||||
/* pick the remainder */
|
/* pick the remainder */
|
||||||
for (ref = src; ref; ref = ref->next) {
|
for (ref = src; ref; ref = ref->next) {
|
||||||
@ -1310,7 +1307,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, 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;
|
||||||
|
|
||||||
@ -1359,7 +1356,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, 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);
|
||||||
@ -1372,8 +1369,6 @@ int match_push_refs(struct ref *src, struct ref **dst,
|
|||||||
string_list_clear(&src_ref_index, 0);
|
string_list_clear(&src_ref_index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
refspec_clear(&rs);
|
|
||||||
|
|
||||||
if (errs)
|
if (errs)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
2
remote.h
2
remote.h
@ -163,7 +163,7 @@ char *apply_refspecs(struct refspec *rs, const char *name);
|
|||||||
|
|
||||||
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
|
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
|
||||||
int match_push_refs(struct ref *src, struct ref **dst,
|
int match_push_refs(struct ref *src, struct ref **dst,
|
||||||
int nr_refspec, const char **refspec, int all);
|
struct refspec *rs, int flags);
|
||||||
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
||||||
int force_update);
|
int force_update);
|
||||||
|
|
||||||
|
@ -1127,10 +1127,8 @@ int transport_push(struct transport *transport,
|
|||||||
if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
|
if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
|
||||||
match_flags |= MATCH_REFS_FOLLOW_TAGS;
|
match_flags |= MATCH_REFS_FOLLOW_TAGS;
|
||||||
|
|
||||||
if (match_push_refs(local_refs, &remote_refs,
|
if (match_push_refs(local_refs, &remote_refs, rs, match_flags))
|
||||||
rs->raw_nr, rs->raw, match_flags)) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (transport->smart_options &&
|
if (transport->smart_options &&
|
||||||
transport->smart_options->cas &&
|
transport->smart_options->cas &&
|
||||||
|
Loading…
Reference in New Issue
Block a user