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>
Daniel Barkalow committed
Jul 10, 2007 at 00:47 UTC
1d735267c9fb74892b0db41b567dc55dcc878006
1 file changed
+11
-10
remote.c
+11
-10
@@ -396,11 +396,12 @@ static int count_refspec_match(const char *pattern,
396
}
397
}
398
399
-static void link_dst_tail(struct ref *ref, struct ref ***tail)
399
+static void tail_link_ref(struct ref *ref, struct ref ***tail)
400
{
401
**tail = ref;
402
+ while (ref->next)
403
+ ref = ref->next;
404
*tail = &ref->next;
403
- **tail = NULL;
405
}
406
407
static struct ref *try_explicit_object_name(const char *name)
@@ -424,16 +425,16 @@ static struct ref *try_explicit_object_name(const char *name)
425
return ref;
426
}
427
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)
429
{
429
- struct ref *dst;
430
+ struct ref *ret;
431
size_t len;
432
433
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;
438
}
439
440
static int match_explicit(struct ref *src, struct ref *dst,
@@ -481,7 +482,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
482
break;
483
case 0:
484
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);
486
else
487
error("dst refspec %s does not match any "
488
"existing ref on the remote and does "
@@ -591,7 +592,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
592
goto free_name;
593
if (!dst_peer) {
594
/* 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);
596
hashcpy(dst_peer->new_sha1, src->new_sha1);
597
}
598
dst_peer->peer_ref = src;