diff options
author | Brandon Williams <bmwill@google.com> | 2018-05-16 15:58:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-18 06:19:44 +0900 |
commit | 5c7ec8462d8706f9731f0d54ea3fdfe810d60a88 (patch) | |
tree | 806f0fd0f8850ed22298cd882a056c99c101bdd9 /remote.c | |
parent | 38490dd416af41ce65eab0fc91de14009c73d606 (diff) | |
download | git-5c7ec8462d8706f9731f0d54ea3fdfe810d60a88.tar.gz |
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>
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -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). */ 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_mirror = flags & MATCH_REFS_MIRROR; int send_prune = flags & MATCH_REFS_PRUNE; int errs; - static const char *default_refspec[] = { ":", NULL }; struct ref *ref, **dst_tail = tail_ref(dst); struct string_list dst_ref_index = STRING_LIST_INIT_NODUP; - if (!nr_refspec) { - nr_refspec = 1; - refspec = default_refspec; - } - refspec_appendn(&rs, refspec, nr_refspec); - errs = match_explicit_refs(src, *dst, &dst_tail, &rs); + /* If no refspec is provided, use the default ":" */ + if (!rs->nr) + refspec_append(rs, ":"); + + errs = match_explicit_refs(src, *dst, &dst_tail, rs); /* pick the remainder */ 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; 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) continue; @@ -1359,7 +1356,7 @@ int match_push_refs(struct ref *src, struct ref **dst, /* We're already sending something to this ref. */ 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_ref_index.nr) 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); } - refspec_clear(&rs); - if (errs) return -1; return 0; |