Skip to content

Commit 4db34cc

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1c71541 commit 4db34cc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

fast-import.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,7 @@ static int parse_from(struct branch *b)
26132613

26142614
static struct hash_list *parse_merge(unsigned int *count)
26152615
{
2616-
struct hash_list *list = NULL, *n, *e = e;
2616+
struct hash_list *list = NULL, **tail = &list, *n;
26172617
const char *from;
26182618
struct branch *s;
26192619

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

26432643
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+
26492647
(*count)++;
26502648
read_next_command();
26512649
}

0 commit comments

Comments
 (0)