refspec: rename struct refspec to struct refspec_item

In preparation for introducing an abstraction around a collection of refspecs (much like how a 'struct pathspec' is a collection of 'struct pathspec_item's) rename the existing 'struct refspec' to 'struct refspec_item'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 16, 2018 at 15:57 UTC 0ad4a5ff50dbc839ae26aa60c03b55bf416b6000
15 files changed +73 -73
branch.c
+3 -3
@@ -9,7 +9,7 @@
9 #include "worktree.h"
10
11 struct tracking {
12 - struct refspec spec;
12 + struct refspec_item spec;
13 char *src;
14 const char *remote;
15 int matches;
@@ -219,8 +219,8 @@ int validate_new_branchname(const char *name, struct strbuf *ref, int force)
219 static int check_tracking_branch(struct remote *remote, void *cb_data)
220 {
221 char *tracking_branch = cb_data;
222 - struct refspec query;
223 - memset(&query, 0, sizeof(struct refspec));
222 + struct refspec_item query;
223 + memset(&query, 0, sizeof(struct refspec_item));
224 query.dst = tracking_branch;
225 return !remote_find_tracking(remote, &query);
226 }
builtin/clone.c
+2 -2
@@ -547,7 +547,7 @@ static struct ref *find_remote_branch(const struct ref *refs, const char *branch
547 }
548
549 static struct ref *wanted_peer_refs(const struct ref *refs,
550 - struct refspec *refspec)
550 + struct refspec_item *refspec)
551 {
552 struct ref *head = copy_ref(find_ref_by_name(refs, "HEAD"));
553 struct ref *local_refs = head;
@@ -895,7 +895,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
895 int err = 0, complete_refs_before_fetch = 1;
896 int submodule_progress;
897
898 - struct refspec *refspec;
898 + struct refspec_item *refspec;
899 const char *fetch_pattern;
900
901 fetch_if_missing = 0;
builtin/fast-export.c
+2 -2
@@ -36,7 +36,7 @@ static int use_done_feature;
36 static int no_data;
37 static int full_tree;
38 static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
39 -static struct refspec *refspecs;
39 +static struct refspec_item *refspecs;
40 static int refspecs_nr;
41 static int anonymize;
42
@@ -979,7 +979,7 @@ static void handle_deletes(void)
979 {
980 int i;
981 for (i = 0; i < refspecs_nr; i++) {
982 - struct refspec *refspec = &refspecs[i];
982 + struct refspec_item *refspec = &refspecs[i];
983 if (*refspec->src)
984 continue;
985
builtin/fetch.c
+6 -6
@@ -203,7 +203,7 @@ static void add_merge_config(struct ref **head,
203
204 for (i = 0; i < branch->merge_nr; i++) {
205 struct ref *rm, **old_tail = *tail;
206 - struct refspec refspec;
206 + struct refspec_item refspec;
207
208 for (rm = *head; rm; rm = rm->next) {
209 if (branch_merge_matches(branch, i, rm->name)) {
@@ -340,7 +340,7 @@ static void find_non_local_tags(struct transport *transport,
340 }
341
342 static struct ref *get_ref_map(struct transport *transport,
343 - struct refspec *refspecs, int refspec_count,
343 + struct refspec_item *refspecs, int refspec_count,
344 int tags, int *autotags)
345 {
346 int i;
@@ -371,7 +371,7 @@ static struct ref *get_ref_map(struct transport *transport,
371 argv_array_clear(&ref_prefixes);
372
373 if (refspec_count) {
374 - struct refspec *fetch_refspec;
374 + struct refspec_item *fetch_refspec;
375 int fetch_refspec_nr;
376
377 for (i = 0; i < refspec_count; i++) {
@@ -965,7 +965,7 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
965 return ret;
966 }
967
968 -static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
968 +static int prune_refs(struct refspec_item *refs, int ref_count, struct ref *ref_map,
969 const char *raw_url)
970 {
971 int url_len, i, result = 0;
@@ -1115,7 +1115,7 @@ static void backfill_tags(struct transport *transport, struct ref *ref_map)
1115 }
1116
1117 static int do_fetch(struct transport *transport,
1118 - struct refspec *refs, int ref_count)
1118 + struct refspec_item *refs, int ref_count)
1119 {
1120 struct string_list existing_refs = STRING_LIST_INIT_DUP;
1121 struct ref *ref_map;
@@ -1357,7 +1357,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
1357 static int fetch_one(struct remote *remote, int argc, const char **argv, int prune_tags_ok)
1358 {
1359 static const char **refs = NULL;
1360 - struct refspec *refspec;
1360 + struct refspec_item *refspec;
1361 int ref_nr = 0;
1362 int j = 0;
1363 int exit_code;
builtin/pull.c
+1 -1
@@ -676,7 +676,7 @@ static const char *get_upstream_branch(const char *remote)
676 */
677 static const char *get_tracking_branch(const char *remote, const char *refspec)
678 {
679 - struct refspec *spec;
679 + struct refspec_item *spec;
680 const char *spec_src;
681 const char *merge_branch;
682
builtin/push.c
+2 -2
@@ -80,8 +80,8 @@ static const char *map_refspec(const char *ref,
80 return ref;
81
82 if (remote->push) {
83 - struct refspec query;
84 - memset(&query, 0, sizeof(struct refspec));
83 + struct refspec_item query;
84 + memset(&query, 0, sizeof(struct refspec_item));
85 query.src = matched->name;
86 if (!query_refspecs(remote->push, remote->push_refspec_nr, &query) &&
87 query.dst) {
builtin/remote.c
+4 -4
@@ -442,7 +442,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
442 info->dest = xstrdup(item->string);
443 }
444 for (i = 0; i < remote->push_refspec_nr; i++) {
445 - struct refspec *spec = remote->push + i;
445 + struct refspec_item *spec = remote->push + i;
446 if (spec->matching)
447 item = string_list_append(&states->push, _("(matching)"));
448 else if (strlen(spec->src))
@@ -462,7 +462,7 @@ static int get_head_names(const struct ref *remote_refs, struct ref_states *stat
462 {
463 struct ref *ref, *matches;
464 struct ref *fetch_map = NULL, **fetch_map_tail = &fetch_map;
465 - struct refspec refspec;
465 + struct refspec_item refspec;
466
467 refspec.force = 0;
468 refspec.pattern = 1;
@@ -515,7 +515,7 @@ static int add_branch_for_removal(const char *refname,
515 const struct object_id *oid, int flags, void *cb_data)
516 {
517 struct branches_for_remote *branches = cb_data;
518 - struct refspec refspec;
518 + struct refspec_item refspec;
519 struct known_remote *kr;
520
521 memset(&refspec, 0, sizeof(refspec));
@@ -834,7 +834,7 @@ static int append_ref_to_tracked_list(const char *refname,
834 const struct object_id *oid, int flags, void *cb_data)
835 {
836 struct ref_states *states = cb_data;
837 - struct refspec refspec;
837 + struct refspec_item refspec;
838
839 if (flags & REF_ISSYMREF)
840 return 0;
builtin/submodule--helper.c
+2 -2
@@ -1746,11 +1746,11 @@ static int push_check(int argc, const char **argv, const char *prefix)
1746 if (argc > 2) {
1747 int i, refspec_nr = argc - 2;
1748 struct ref *local_refs = get_local_heads();
1749 - struct refspec *refspec = parse_push_refspec(refspec_nr,
1749 + struct refspec_item *refspec = parse_push_refspec(refspec_nr,
1750 argv + 2);
1751
1752 for (i = 0; i < refspec_nr; i++) {
1753 - struct refspec *rs = refspec + i;
1753 + struct refspec_item *rs = refspec + i;
1754
1755 if (rs->pattern || rs->matching)
1756 continue;
checkout.c
+2 -2
@@ -13,8 +13,8 @@ struct tracking_name_data {
13 static int check_tracking_name(struct remote *remote, void *cb_data)
14 {
15 struct tracking_name_data *cb = cb_data;
16 - struct refspec query;
17 - memset(&query, 0, sizeof(struct refspec));
16 + struct refspec_item query;
17 + memset(&query, 0, sizeof(struct refspec_item));
18 query.src = cb->src_ref;
19 if (remote_find_tracking(remote, &query) ||
20 get_oid(query.dst, cb->dst_oid)) {
refspec.c
+8 -8
@@ -2,7 +2,7 @@
2 #include "refs.h"
3 #include "refspec.h"
4
5 -static struct refspec s_tag_refspec = {
5 +static struct refspec_item s_tag_refspec = {
6 0,
7 1,
8 0,
@@ -12,12 +12,12 @@ static struct refspec s_tag_refspec = {
12 };
13
14 /* See TAG_REFSPEC for the string version */
15 -const struct refspec *tag_refspec = &s_tag_refspec;
15 +const struct refspec_item *tag_refspec = &s_tag_refspec;
16
17 -static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
17 +static struct refspec_item *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
18 {
19 int i;
20 - struct refspec *rs = xcalloc(nr_refspec, sizeof(*rs));
20 + struct refspec_item *rs = xcalloc(nr_refspec, sizeof(*rs));
21
22 for (i = 0; i < nr_refspec; i++) {
23 size_t llen;
@@ -135,24 +135,24 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
135
136 int valid_fetch_refspec(const char *fetch_refspec_str)
137 {
138 - struct refspec *refspec;
138 + struct refspec_item *refspec;
139
140 refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
141 free_refspec(1, refspec);
142 return !!refspec;
143 }
144
145 -struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec)
145 +struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec)
146 {
147 return parse_refspec_internal(nr_refspec, refspec, 1, 0);
148 }
149
150 -struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
150 +struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec)
151 {
152 return parse_refspec_internal(nr_refspec, refspec, 0, 0);
153 }
154
155 -void free_refspec(int nr_refspec, struct refspec *refspec)
155 +void free_refspec(int nr_refspec, struct refspec_item *refspec)
156 {
157 int i;
158
refspec.h
+5 -5
@@ -2,9 +2,9 @@
2 #define REFSPEC_H
3
4 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
5 -extern const struct refspec *tag_refspec;
5 +extern const struct refspec_item *tag_refspec;
6
7 -struct refspec {
7 +struct refspec_item {
8 unsigned force : 1;
9 unsigned pattern : 1;
10 unsigned matching : 1;
@@ -15,9 +15,9 @@ struct refspec {
15 };
16
17 int valid_fetch_refspec(const char *refspec);
18 -struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
19 -struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
18 +struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
19 +struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
20
21 -void free_refspec(int nr_refspec, struct refspec *refspec);
21 +void free_refspec(int nr_refspec, struct refspec_item *refspec);
22
23 #endif /* REFSPEC_H */
remote.c
+25 -25
@@ -97,7 +97,7 @@ void add_prune_tags_to_fetch_refspec(struct remote *remote)
97 {
98 int nr = remote->fetch_refspec_nr;
99 int bufsize = nr + 1;
100 - int size = sizeof(struct refspec);
100 + int size = sizeof(struct refspec_item);
101
102 remote->fetch = xrealloc(remote->fetch, size * bufsize);
103 memcpy(&remote->fetch[nr], tag_refspec, size);
@@ -724,7 +724,7 @@ static int match_name_with_pattern(const char *key, const char *name,
724 return ret;
725 }
726
727 -static void query_refspecs_multiple(struct refspec *refs, int ref_count, struct refspec *query, struct string_list *results)
727 +static void query_refspecs_multiple(struct refspec_item *refs, int ref_count, struct refspec_item *query, struct string_list *results)
728 {
729 int i;
730 int find_src = !query->src;
@@ -733,7 +733,7 @@ static void query_refspecs_multiple(struct refspec *refs, int ref_count, struct
733 error("query_refspecs_multiple: need either src or dst");
734
735 for (i = 0; i < ref_count; i++) {
736 - struct refspec *refspec = &refs[i];
736 + struct refspec_item *refspec = &refs[i];
737 const char *key = find_src ? refspec->dst : refspec->src;
738 const char *value = find_src ? refspec->src : refspec->dst;
739 const char *needle = find_src ? query->dst : query->src;
@@ -750,7 +750,7 @@ static void query_refspecs_multiple(struct refspec *refs, int ref_count, struct
750 }
751 }
752
753 -int query_refspecs(struct refspec *refs, int ref_count, struct refspec *query)
753 +int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item *query)
754 {
755 int i;
756 int find_src = !query->src;
@@ -761,7 +761,7 @@ int query_refspecs(struct refspec *refs, int ref_count, struct refspec *query)
761 return error("query_refspecs: need either src or dst");
762
763 for (i = 0; i < ref_count; i++) {
764 - struct refspec *refspec = &refs[i];
764 + struct refspec_item *refspec = &refs[i];
765 const char *key = find_src ? refspec->dst : refspec->src;
766 const char *value = find_src ? refspec->src : refspec->dst;
767
@@ -781,12 +781,12 @@ int query_refspecs(struct refspec *refs, int ref_count, struct refspec *query)
781 return -1;
782 }
783
784 -char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
784 +char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
785 const char *name)
786 {
787 - struct refspec query;
787 + struct refspec_item query;
788
789 - memset(&query, 0, sizeof(struct refspec));
789 + memset(&query, 0, sizeof(struct refspec_item));
790 query.src = (char *)name;
791
792 if (query_refspecs(refspecs, nr_refspec, &query))
@@ -795,7 +795,7 @@ char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
795 return query.dst;
796 }
797
798 -int remote_find_tracking(struct remote *remote, struct refspec *refspec)
798 +int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
799 {
800 return query_refspecs(remote->fetch, remote->fetch_refspec_nr, refspec);
801 }
@@ -1004,7 +1004,7 @@ static char *guess_ref(const char *name, struct ref *peer)
1004 }
1005
1006 static int match_explicit_lhs(struct ref *src,
1007 - struct refspec *rs,
1007 + struct refspec_item *rs,
1008 struct ref **match,
1009 int *allocated_match)
1010 {
@@ -1030,7 +1030,7 @@ static int match_explicit_lhs(struct ref *src,
1030
1031 static int match_explicit(struct ref *src, struct ref *dst,
1032 struct ref ***dst_tail,
1033 - struct refspec *rs)
1033 + struct refspec_item *rs)
1034 {
1035 struct ref *matched_src, *matched_dst;
1036 int allocated_src;
@@ -1099,7 +1099,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
1099 }
1100
1101 static int match_explicit_refs(struct ref *src, struct ref *dst,
1102 - struct ref ***dst_tail, struct refspec *rs,
1102 + struct ref ***dst_tail, struct refspec_item *rs,
1103 int rs_nr)
1104 {
1105 int i, errs;
@@ -1108,10 +1108,10 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
1108 return errs;
1109 }
1110
1111 -static char *get_ref_match(const struct refspec *rs, int rs_nr, const struct ref *ref,
1112 - int send_mirror, int direction, const struct refspec **ret_pat)
1111 +static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struct ref *ref,
1112 + int send_mirror, int direction, const struct refspec_item **ret_pat)
1113 {
1114 - const struct refspec *pat;
1114 + const struct refspec_item *pat;
1115 char *name;
1116 int i;
1117 int matching_refs = -1;
@@ -1282,12 +1282,12 @@ static void prepare_ref_index(struct string_list *ref_index, struct ref *ref)
1282 */
1283 int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
1284 {
1285 - struct refspec *refspec = parse_push_refspec(nr_refspec, refspec_names);
1285 + struct refspec_item *refspec = parse_push_refspec(nr_refspec, refspec_names);
1286 int ret = 0;
1287 int i;
1288
1289 for (i = 0; i < nr_refspec; i++) {
1290 - struct refspec *rs = refspec + i;
1290 + struct refspec_item *rs = refspec + i;
1291
1292 if (rs->pattern || rs->matching)
1293 continue;
@@ -1310,7 +1310,7 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
1310 int match_push_refs(struct ref *src, struct ref **dst,
1311 int nr_refspec, const char **refspec, int flags)
1312 {
1313 - struct refspec *rs;
1313 + struct refspec_item *rs;
1314 int send_all = flags & MATCH_REFS_ALL;
1315 int send_mirror = flags & MATCH_REFS_MIRROR;
1316 int send_prune = flags & MATCH_REFS_PRUNE;
@@ -1330,7 +1330,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1330 for (ref = src; ref; ref = ref->next) {
1331 struct string_list_item *dst_item;
1332 struct ref *dst_peer;
1333 - const struct refspec *pat = NULL;
1333 + const struct refspec_item *pat = NULL;
1334 char *dst_name;
1335
1336 dst_name = get_ref_match(rs, nr_refspec, ref, send_mirror, FROM_SRC, &pat);
@@ -1686,7 +1686,7 @@ static int ignore_symref_update(const char *refname)
1686 * local symbolic ref.
1687 */
1688 static struct ref *get_expanded_map(const struct ref *remote_refs,
1689 - const struct refspec *refspec)
1689 + const struct refspec_item *refspec)
1690 {
1691 const struct ref *ref;
1692 struct ref *ret = NULL;
@@ -1751,7 +1751,7 @@ static struct ref *get_local_ref(const char *name)
1751 }
1752
1753 int get_fetch_map(const struct ref *remote_refs,
1754 - const struct refspec *refspec,
1754 + const struct refspec_item *refspec,
1755 struct ref ***tail,
1756 int missing_ok)
1757 {
@@ -2089,7 +2089,7 @@ struct ref *guess_remote_head(const struct ref *head,
2089 struct stale_heads_info {
2090 struct string_list *ref_names;
2091 struct ref **stale_refs_tail;
2092 - struct refspec *refs;
2092 + struct refspec_item *refs;
2093 int ref_count;
2094 };
2095
@@ -2098,9 +2098,9 @@ static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
2098 {
2099 struct stale_heads_info *info = cb_data;
2100 struct string_list matches = STRING_LIST_INIT_DUP;
2101 - struct refspec query;
2101 + struct refspec_item query;
2102 int i, stale = 1;
2103 - memset(&query, 0, sizeof(struct refspec));
2103 + memset(&query, 0, sizeof(struct refspec_item));
2104 query.dst = (char *)refname;
2105
2106 query_refspecs_multiple(info->refs, info->ref_count, &query, &matches);
@@ -2131,7 +2131,7 @@ clean_exit:
2131 return 0;
2132 }
2133
2134 -struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fetch_map)
2134 +struct ref *get_stale_heads(struct refspec_item *refs, int ref_count, struct ref *fetch_map)
2135 {
2136 struct ref *ref, *stale_refs = NULL;
2137 struct string_list ref_names = STRING_LIST_INIT_NODUP;
remote.h
+8 -8
@@ -28,12 +28,12 @@ struct remote {
28 int pushurl_alloc;
29
30 const char **push_refspec;
31 - struct refspec *push;
31 + struct refspec_item *push;
32 int push_refspec_nr;
33 int push_refspec_alloc;
34
35 const char **fetch_refspec;
36 - struct refspec *fetch;
36 + struct refspec_item *fetch;
37 int fetch_refspec_nr;
38 int fetch_refspec_alloc;
39
@@ -163,8 +163,8 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
163 */
164 struct ref *ref_remove_duplicates(struct ref *ref_map);
165
166 -extern int query_refspecs(struct refspec *specs, int nr, struct refspec *query);
167 -char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
166 +extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
167 +char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
168 const char *name);
169
170 int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
@@ -185,7 +185,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
185 * missing_ok is usually false, but when we are adding branch.$name.merge
186 * it is Ok if the branch is not at the remote anymore.
187 */
188 -int get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec,
188 +int get_fetch_map(const struct ref *remote_refs, const struct refspec_item *refspec,
189 struct ref ***tail, int missing_ok);
190
191 struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
@@ -193,7 +193,7 @@ struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
193 /*
194 * For the given remote, reads the refspec's src and sets the other fields.
195 */
196 -int remote_find_tracking(struct remote *remote, struct refspec *refspec);
196 +int remote_find_tracking(struct remote *remote, struct refspec_item *refspec);
197
198 struct branch {
199 const char *name;
@@ -203,7 +203,7 @@ struct branch {
203 const char *pushremote_name;
204
205 const char **merge_name;
206 - struct refspec **merge;
206 + struct refspec_item **merge;
207 int merge_nr;
208 int merge_alloc;
209
@@ -272,7 +272,7 @@ struct ref *guess_remote_head(const struct ref *head,
272 int all);
273
274 /* Return refs which no longer exist on remote */
275 -struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fetch_map);
275 +struct ref *get_stale_heads(struct refspec_item *refs, int ref_count, struct ref *fetch_map);
276
277 /*
278 * Compare-and-swap
transport-helper.c
+1 -1
@@ -36,7 +36,7 @@ struct helper_data {
36 char *export_marks;
37 char *import_marks;
38 /* These go from remote name (as in "list") to private name */
39 - struct refspec *refspecs;
39 + struct refspec_item *refspecs;
40 int refspec_nr;
41 /* Transport options for fetch-pack/send-pack (should one of
42 * those be invoked).
transport.c
+2 -2
@@ -390,7 +390,7 @@ int transport_refs_pushed(struct ref *ref)
390
391 void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
392 {
393 - struct refspec rs;
393 + struct refspec_item rs;
394
395 if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
396 return;
@@ -1111,7 +1111,7 @@ int transport_push(struct transport *transport,
1111 int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
1112 int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
1113 int push_ret, ret, err;
1114 - struct refspec *tmp_rs;
1114 + struct refspec_item *tmp_rs;
1115 struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
1116 int i;
1117