Skip to content

Commit

Permalink
fast-import: use pointer-to-pointer to keep list tail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 21, 2013
1 parent 1c71541 commit 4db34cc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,7 @@ static int parse_from(struct branch *b)

static struct hash_list *parse_merge(unsigned int *count)
{
struct hash_list *list = NULL, *n, *e = e;
struct hash_list *list = NULL, **tail = &list, *n;
const char *from;
struct branch *s;

Expand Down Expand Up @@ -2641,11 +2641,9 @@ static struct hash_list *parse_merge(unsigned int *count)
die("Invalid ref name or SHA1 expression: %s", from);

n->next = NULL;
if (list)
e->next = n;
else
list = n;
e = n;
*tail = n;
tail = &n->next;

(*count)++;
read_next_command();
}
Expand Down

0 comments on commit 4db34cc

Please sign in to comment.