Skip to content

Commit 1d73526

Browse files
iabervongitster
authored andcommitted
Some cosmetic changes to remote library
Functions for managing ref lists were named based on their use in match_refs (for push). For fetch, they will be used for other purposes, so rename them as a separate patch to make the future code readable. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent dfd255d commit 1d73526

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

remote.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,12 @@ static int count_refspec_match(const char *pattern,
396396
}
397397
}
398398

399-
static void link_dst_tail(struct ref *ref, struct ref ***tail)
399+
static void tail_link_ref(struct ref *ref, struct ref ***tail)
400400
{
401401
**tail = ref;
402+
while (ref->next)
403+
ref = ref->next;
402404
*tail = &ref->next;
403-
**tail = NULL;
404405
}
405406

406407
static struct ref *try_explicit_object_name(const char *name)
@@ -424,16 +425,16 @@ static struct ref *try_explicit_object_name(const char *name)
424425
return ref;
425426
}
426427

427-
static struct ref *make_dst(const char *name, struct ref ***dst_tail)
428+
static struct ref *make_linked_ref(const char *name, struct ref ***tail)
428429
{
429-
struct ref *dst;
430+
struct ref *ret;
430431
size_t len;
431432

432433
len = strlen(name) + 1;
433-
dst = alloc_ref(len);
434-
memcpy(dst->name, name, len);
435-
link_dst_tail(dst, dst_tail);
436-
return dst;
434+
ret = alloc_ref(len);
435+
memcpy(ret->name, name, len);
436+
tail_link_ref(ret, tail);
437+
return ret;
437438
}
438439

439440
static int match_explicit(struct ref *src, struct ref *dst,
@@ -481,7 +482,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
481482
break;
482483
case 0:
483484
if (!memcmp(dst_value, "refs/", 5))
484-
matched_dst = make_dst(dst_value, dst_tail);
485+
matched_dst = make_linked_ref(dst_value, dst_tail);
485486
else
486487
error("dst refspec %s does not match any "
487488
"existing ref on the remote and does "
@@ -591,7 +592,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
591592
goto free_name;
592593
if (!dst_peer) {
593594
/* Create a new one and link it */
594-
dst_peer = make_dst(dst_name, dst_tail);
595+
dst_peer = make_linked_ref(dst_name, dst_tail);
595596
hashcpy(dst_peer->new_sha1, src->new_sha1);
596597
}
597598
dst_peer->peer_ref = src;

0 commit comments

Comments
 (0)