append to tail of reflist, not to the head of the list
diff --git a/lib/reference.c b/lib/reference.c
index 617c921..5bf2f2a 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -491,7 +491,7 @@ insert_ref(struct got_reflist_head *refs, struct got_reference *ref,
if (prev)
SIMPLEQ_INSERT_AFTER(refs, prev, re, entry);
else
- SIMPLEQ_INSERT_HEAD(refs, re, entry);
+ SIMPLEQ_INSERT_TAIL(refs, re, entry);
return NULL;
}