fast-import: use pointer-to-pointer to keep list tail
This is shorter, idiomatic, and it means the compiler does not get confused about whether our "e" pointer is valid, letting us drop the "e = e" hack. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 21, 2013 at 07:08 UTC
4db34cc134978012cf3f1b07de981a0418ed1523
1 file changed
+4
-6
fast-import.c
+4
-6
@@ -2613,7 +2613,7 @@ static int parse_from(struct branch *b)
2613
2614
static struct hash_list *parse_merge(unsigned int *count)
2615
{
2616
- struct hash_list *list = NULL, *n, *e = e;
2616
+ struct hash_list *list = NULL, **tail = &list, *n;
2617
const char *from;
2618
struct branch *s;
2619
@@ -2641,11 +2641,9 @@ static struct hash_list *parse_merge(unsigned int *count)
2641
die("Invalid ref name or SHA1 expression: %s", from);
2642
2643
n->next = NULL;
2644
- if (list)
2645
- e->next = n;
2646
- else
2647
- list = n;
2648
- e = n;
2644
+ *tail = n;
2645
+ tail = &n->next;
2646
+
2647
(*count)++;
2648
read_next_command();
2649
}