Skip to content

Commit 29753cd

Browse files
committed
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 <[email protected]>
1 parent e6bcd97 commit 29753cd

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

builtin/remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ static int get_push_ref_states(const struct ref *remote_refs,
389389
local_refs = get_local_heads();
390390
push_map = copy_ref_list(remote_refs);
391391

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);
394394

395395
states->push.strdup_strings = 1;
396396
for (ref = push_map; ref; ref = ref->next) {

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
509509
flags |= MATCH_REFS_MIRROR;
510510

511511
/* 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))
513513
return -1;
514514

515515
set_ref_status_for_push(remote_refs, args.send_mirror,

http-push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,8 +1877,8 @@ int main(int argc, char **argv)
18771877
}
18781878

18791879
/* 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)) {
18821882
rc = -1;
18831883
goto cleanup;
18841884
}

remote.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,12 +1170,15 @@ static struct ref **tail_ref(struct ref **head)
11701170
}
11711171

11721172
/*
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).
11761179
*/
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)
11791182
{
11801183
struct refspec *rs;
11811184
int send_all = flags & MATCH_REFS_ALL;

remote.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ void free_refspec(int nr_refspec, struct refspec *refspec);
9696
char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
9797
const char *name);
9898

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);
101101
void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
102102
int force_update);
103103

transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ int transport_push(struct transport *transport,
10331033
if (flags & TRANSPORT_PUSH_MIRROR)
10341034
match_flags |= MATCH_REFS_MIRROR;
10351035

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)) {
10381038
return -1;
10391039
}
10401040

0 commit comments

Comments
 (0)