diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2017-06-15 02:43:56 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-21 15:44:37 -0700 |
commit | 145a7449789e259b81f9a8c61ba9e9ef7b062f9b (patch) | |
tree | 3e7b2ae39c24d37ca75a9ca0be315195db388fd9 /builtin/remote.c | |
parent | eb0c621d1ec952048bc0b2222e2dd81f1fe58dbd (diff) | |
download | git-sg/remote-no-string-refspecs.tar.gz |
remote.c: eliminate remote->push_refspecsg/remote-no-string-refspecs
Do the same as in the previous patch, but for push refspecs, i.e. with
remote->push_refspec, remote->push and add_push_refspec().
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r-- | builtin/remote.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index d61daa5e8d..c04dec0e1a 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -380,14 +380,19 @@ static int get_push_ref_states(const struct ref *remote_refs, { struct remote *remote = states->remote; struct ref *ref, *local_refs, *push_map; + const char **refspec; + int i; if (remote->mirror) return 0; local_refs = get_local_heads(); push_map = copy_ref_list(remote_refs); - match_push_refs(local_refs, &push_map, remote->push_refspec_nr, - remote->push_refspec, MATCH_REFS_NONE); + ALLOC_ARRAY(refspec, remote->push.nr); + for (i = 0; i < remote->push.nr; i++) + refspec[i] = refspec_to_string(&remote->push.rs[i]); + match_push_refs(local_refs, &push_map, remote->push.nr, + refspec, MATCH_REFS_NONE); states->push.strdup_strings = 1; for (ref = push_map; ref; ref = ref->next) { @@ -433,14 +438,14 @@ static int get_push_ref_states_noquery(struct ref_states *states) return 0; states->push.strdup_strings = 1; - if (!remote->push_refspec_nr) { + if (!remote->push.nr) { item = string_list_append(&states->push, _("(matching)")); info = item->util = xcalloc(1, sizeof(struct push_info)); info->status = PUSH_STATUS_NOTQUERIED; info->dest = xstrdup(item->string); } - for (i = 0; i < remote->push_refspec_nr; i++) { - struct refspec *spec = remote->push + i; + for (i = 0; i < remote->push.nr; i++) { + struct refspec *spec = remote->push.rs + i; if (spec->matching) item = string_list_append(&states->push, _("(matching)")); else if (strlen(spec->src)) @@ -584,8 +589,8 @@ static int migrate_file(struct remote *remote) git_config_set_multivar(buf.buf, remote->url[i], "^$", 0); strbuf_reset(&buf); strbuf_addf(&buf, "remote.%s.push", remote->name); - for (i = 0; i < remote->push_refspec_nr; i++) { - strbuf_add_refspec(&refspec, &remote->push[i]); + for (i = 0; i < remote->push.nr; i++) { + strbuf_add_refspec(&refspec, &remote->push.rs[i]); git_config_set_multivar(buf.buf, refspec.buf, "^$", 0); strbuf_reset(&refspec); } |