commit f68a789010192e18ab34908cd5fde2d531c35fdc from: Stefan Sperling date: Thu Mar 19 09:07:46 2020 UTC make got_ref_list() work on a fresh repository created with got_repo_init() commit - 5afa897608bec45e640a03fdb7789e8be18e3a9a commit + f68a789010192e18ab34908cd5fde2d531c35fdc blob - 135fe2d60c175b7dccea9c7781d3876385dddfa7 blob + c0ccfc9a9acb2eed45a59f61406b247bce4ce4ad --- lib/reference.c +++ lib/reference.c @@ -868,7 +868,6 @@ got_ref_list(struct got_reflist_head *refs, struct got struct got_reflist_entry *new; if (ref_namespace == NULL || ref_namespace[0] == '\0') { - /* HEAD ref should always exist. */ path_refs = get_refs_dir_path(repo, GOT_REF_HEAD); if (path_refs == NULL) { err = got_error_from_errno("get_refs_dir_path"); @@ -877,10 +876,11 @@ got_ref_list(struct got_reflist_head *refs, struct got err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0); if (err) goto done; - err = insert_ref(&new, refs, ref, repo, cmp_cb, cmp_arg); + err = insert_ref(&new, refs, ref, repo, + cmp_cb, cmp_arg); if (err || new == NULL /* duplicate */) got_ref_close(ref); - if (err) + if (err && err->code != GOT_ERR_NOT_REF) goto done; }