rename "match_refs()" to "match_push_refs()"

Yes, there is a warning that says the function is only used by push in big red letters in front of this function, but it didn't say a more important thing it should have said: what the function is for and what it does. Rename it and document it to avoid future confusion. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 9, 2011 at 11:54 UTC 29753cddc8007ac63754855d026fe5eca8897d04
6 files changed +17 -14
builtin/remote.c
+2 -2
@@ -389,8 +389,8 @@ static int get_push_ref_states(const struct ref *remote_refs,
389 local_refs = get_local_heads();
390 push_map = copy_ref_list(remote_refs);
391
392 - match_refs(local_refs, &push_map, remote->push_refspec_nr,
393 - remote->push_refspec, MATCH_REFS_NONE);
392 + match_push_refs(local_refs, &push_map, remote->push_refspec_nr,
393 + remote->push_refspec, MATCH_REFS_NONE);
394
395 states->push.strdup_strings = 1;
396 for (ref = push_map; ref; ref = ref->next) {
builtin/send-pack.c
+1 -1
@@ -509,7 +509,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
509 flags |= MATCH_REFS_MIRROR;
510
511 /* match them up */
512 - if (match_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))
512 + if (match_push_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))
513 return -1;
514
515 set_ref_status_for_push(remote_refs, args.send_mirror,
http-push.c
+2 -2
@@ -1877,8 +1877,8 @@ int main(int argc, char **argv)
1877 }
1878
1879 /* match them up */
1880 - if (match_refs(local_refs, &remote_refs,
1881 - nr_refspec, (const char **) refspec, push_all)) {
1880 + if (match_push_refs(local_refs, &remote_refs,
1881 + nr_refspec, (const char **) refspec, push_all)) {
1882 rc = -1;
1883 goto cleanup;
1884 }
remote.c
+8 -5
@@ -1170,12 +1170,15 @@ static struct ref **tail_ref(struct ref **head)
1170 }
1171
1172 /*
1173 - * Note. This is used only by "push"; refspec matching rules for
1174 - * push and fetch are subtly different, so do not try to reuse it
1175 - * without thinking.
1173 + * Given the set of refs the local repository has, the set of refs the
1174 + * remote repository has, and the refspec used for push, determine
1175 + * what remote refs we will update and with what value by setting
1176 + * peer_ref (which object is being pushed) and force (if the push is
1177 + * forced) in elements of "dst". The function may add new elements to
1178 + * dst (e.g. pushing to a new branch, done in match_explicit_refs).
1179 */
1177 -int match_refs(struct ref *src, struct ref **dst,
1178 - int nr_refspec, const char **refspec, int flags)
1180 +int match_push_refs(struct ref *src, struct ref **dst,
1181 + int nr_refspec, const char **refspec, int flags)
1182 {
1183 struct refspec *rs;
1184 int send_all = flags & MATCH_REFS_ALL;
remote.h
+2 -2
@@ -96,8 +96,8 @@ void free_refspec(int nr_refspec, struct refspec *refspec);
96 char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
97 const char *name);
98
99 -int match_refs(struct ref *src, struct ref **dst,
100 - int nr_refspec, const char **refspec, int all);
99 +int match_push_refs(struct ref *src, struct ref **dst,
100 + int nr_refspec, const char **refspec, int all);
101 void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
102 int force_update);
103
transport.c
+2 -2
@@ -1033,8 +1033,8 @@ int transport_push(struct transport *transport,
1033 if (flags & TRANSPORT_PUSH_MIRROR)
1034 match_flags |= MATCH_REFS_MIRROR;
1035
1036 - if (match_refs(local_refs, &remote_refs,
1037 - refspec_nr, refspec, match_flags)) {
1036 + if (match_push_refs(local_refs, &remote_refs,
1037 + refspec_nr, refspec, match_flags)) {
1038 return -1;
1039 }
1040