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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Feb 23, 2012 at 00:43 UTC
b1d8b1f3f17c7550beeff267356bab89e10c6381
1 file changed
+10
-9
remote.c
+10
-9
@@ -1157,7 +1157,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1157
int send_mirror = flags & MATCH_REFS_MIRROR;
1158
int errs;
1159
static const char *default_refspec[] = { ":", NULL };
1160
- struct ref **dst_tail = tail_ref(dst);
1160
+ struct ref *ref, **dst_tail = tail_ref(dst);
1161
1162
if (!nr_refspec) {
1163
nr_refspec = 1;
@@ -1167,14 +1167,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
1167
errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec);
1168
1169
/* pick the remainder */
1170
- for ( ; src; src = src->next) {
1170
+ for (ref = src; ref; ref = ref->next) {
1171
struct ref *dst_peer;
1172
const struct refspec *pat = NULL;
1173
char *dst_name;
1174
- if (src->peer_ref)
1174
+ if (ref->peer_ref)
1175
continue;
1176
1177
- pat = check_pattern_match(rs, nr_refspec, src);
1177
+ pat = check_pattern_match(rs, nr_refspec, ref);
1178
if (!pat)
1179
continue;
1180
@@ -1184,13 +1184,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
1184
* including refs outside refs/heads/ hierarchy, but
1185
* that does not make much sense these days.
1186
*/
1187
- if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
1187
+ if (!send_mirror && prefixcmp(ref->name, "refs/heads/"))
1188
continue;
1189
- dst_name = xstrdup(src->name);
1189
+ dst_name = xstrdup(ref->name);
1190
+
1191
1192
} else {
1193
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,
1195
dst_side, &dst_name))
1196
die("Didn't think it matches any more");
1197
}
@@ -1211,9 +1212,9 @@ int match_push_refs(struct ref *src, struct ref **dst,
1212
1213
/* Create a new one and link it */
1214
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);
1216
}
1216
- dst_peer->peer_ref = copy_ref(src);
1217
+ dst_peer->peer_ref = copy_ref(ref);
1218
dst_peer->force = pat->force;
1219
free_name:
1220
free(dst_name);