Skip to content

Commit b1d8b1f

Browse files
felipecgitster
authored andcommitted
remote: use a local variable in match_push_refs()
So that we can reuse src later on. No functional changes. Will be useful in next patches. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0d66b5 commit b1d8b1f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

remote.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
11571157
int send_mirror = flags & MATCH_REFS_MIRROR;
11581158
int errs;
11591159
static const char *default_refspec[] = { ":", NULL };
1160-
struct ref **dst_tail = tail_ref(dst);
1160+
struct ref *ref, **dst_tail = tail_ref(dst);
11611161

11621162
if (!nr_refspec) {
11631163
nr_refspec = 1;
@@ -1167,14 +1167,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
11671167
errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec);
11681168

11691169
/* pick the remainder */
1170-
for ( ; src; src = src->next) {
1170+
for (ref = src; ref; ref = ref->next) {
11711171
struct ref *dst_peer;
11721172
const struct refspec *pat = NULL;
11731173
char *dst_name;
1174-
if (src->peer_ref)
1174+
if (ref->peer_ref)
11751175
continue;
11761176

1177-
pat = check_pattern_match(rs, nr_refspec, src);
1177+
pat = check_pattern_match(rs, nr_refspec, ref);
11781178
if (!pat)
11791179
continue;
11801180

@@ -1184,13 +1184,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
11841184
* including refs outside refs/heads/ hierarchy, but
11851185
* that does not make much sense these days.
11861186
*/
1187-
if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
1187+
if (!send_mirror && prefixcmp(ref->name, "refs/heads/"))
11881188
continue;
1189-
dst_name = xstrdup(src->name);
1189+
dst_name = xstrdup(ref->name);
1190+
11901191

11911192
} else {
11921193
const char *dst_side = pat->dst ? pat->dst : pat->src;
1193-
if (!match_name_with_pattern(pat->src, src->name,
1194+
if (!match_name_with_pattern(pat->src, ref->name,
11941195
dst_side, &dst_name))
11951196
die("Didn't think it matches any more");
11961197
}
@@ -1211,9 +1212,9 @@ int match_push_refs(struct ref *src, struct ref **dst,
12111212

12121213
/* Create a new one and link it */
12131214
dst_peer = make_linked_ref(dst_name, &dst_tail);
1214-
hashcpy(dst_peer->new_sha1, src->new_sha1);
1215+
hashcpy(dst_peer->new_sha1, ref->new_sha1);
12151216
}
1216-
dst_peer->peer_ref = copy_ref(src);
1217+
dst_peer->peer_ref = copy_ref(ref);
12171218
dst_peer->force = pat->force;
12181219
free_name:
12191220
free(dst_name);

0 commit comments

Comments
 (0)