{"thread":{"id":"8955","subject":"[PATCH 2/2] Some cosmetic changes to remote library","startedAt":"2007-07-10T04:47:26Z","lastAt":"2007-07-10T05:33:02Z","messageCount":2,"participants":["Daniel Barkalow","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"46913","messageId":"Pine.LNX.4.64.0707100045380.6977@iabervon.org","threadId":"8955","inReplyTo":null,"subject":"[PATCH 2/2] Some cosmetic changes to remote library","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-07-10T04:47:26Z","receivedAt":"2007-07-10T04:47:26Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Functions for managing ref lists were named based on their use in\nmatch_refs (for push). For fetch, they will be used for other purposes, so \nrename them as a separate patch to make the future code readable.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n remote.c |   21 +++++++++++----------\n 1 files changed, 11 insertions(+), 10 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex ed39764..0b831c5 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -396,11 +396,12 @@ static int count_refspec_match(const char *pattern,\n \t}\n }\n \n-static void link_dst_tail(struct ref *ref, struct ref ***tail)\n+static void tail_link_ref(struct ref *ref, struct ref ***tail)\n {\n \t**tail = ref;\n+\twhile (ref->next)\n+\t\tref = ref->next;\n \t*tail = &ref->next;\n-\t**tail = NULL;\n }\n \n static struct ref *try_explicit_object_name(const char *name)\n@@ -424,16 +425,16 @@ static struct ref *try_explicit_object_name(const char *name)\n \treturn ref;\n }\n \n-static struct ref *make_dst(const char *name, struct ref ***dst_tail)\n+static struct ref *make_linked_ref(const char *name, struct ref ***tail)\n {\n-\tstruct ref *dst;\n+\tstruct ref *ret;\n \tsize_t len;\n \n \tlen = strlen(name) + 1;\n-\tdst = alloc_ref(len);\n-\tmemcpy(dst->name, name, len);\n-\tlink_dst_tail(dst, dst_tail);\n-\treturn dst;\n+\tret = alloc_ref(len);\n+\tmemcpy(ret->name, name, len);\n+\ttail_link_ref(ret, tail);\n+\treturn ret;\n }\n \n static int match_explicit(struct ref *src, struct ref *dst,\n@@ -481,7 +482,7 @@ static int match_explicit(struct ref *src, struct ref *dst,\n \t\tbreak;\n \tcase 0:\n \t\tif (!memcmp(dst_value, \"refs/\", 5))\n-\t\t\tmatched_dst = make_dst(dst_value, dst_tail);\n+\t\t\tmatched_dst = make_linked_ref(dst_value, dst_tail);\n \t\telse\n \t\t\terror(\"dst refspec %s does not match any \"\n \t\t\t      \"existing ref on the remote and does \"\n@@ -584,7 +585,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\n \t\t\tgoto free_name;\n \t\tif (!dst_peer) {\n \t\t\t/* Create a new one and link it */\n-\t\t\tdst_peer = make_dst(dst_name, dst_tail);\n+\t\t\tdst_peer = make_linked_ref(dst_name, dst_tail);\n \t\t\thashcpy(dst_peer->new_sha1, src->new_sha1);\n \t\t}\n \t\tdst_peer->peer_ref = src;\n-- \n1.5.2.2.1399.g097d5-dirty\n"},{"id":"46916","messageId":"7vr6ngsu0h.fsf@assigned-by-dhcp.cox.net","threadId":"8955","inReplyTo":"Pine.LNX.4.64.0707100045380.6977@iabervon.org","subject":"Re: [PATCH 2/2] Some cosmetic changes to remote library","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-10T05:33:02Z","receivedAt":"2007-07-10T05:33:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for good readability improvements.  Will apply.\n"}]}