commit - 9a8dc2b3ec216fd01b3c33137eb92d98ddadb63e
commit + 779e1159b25b2aa115e6b42f51003b7e2fa7c06b
blob - e330768de849dc0fa39914378bac64b6f8a09c01
blob + f666e84083ffb2ad05eab02a4fe4cc4a06853221
--- include/got_reference.h
+++ include/got_reference.h
/* Free all references on a ref list. */
void got_ref_list_free(struct got_reflist_head *);
+/*
+ * Insert a reference into a reference list.
+ * Return a pointer to the newly allocated list entry in *newp.
+ * If *newp is NULL and no error occured then the specified reference was
+ * already an element of the list. If *newp is not NULL then the reference
+ * was shallow-copied onto the list and should no longer be closed with
+ * got_ref_close(). Instead it will be closed along with other list
+ * elements by got_ref_list_free().
+ */
+const struct got_error *
+got_reflist_insert(struct got_reflist_entry **newp, struct got_reflist_head *refs,
+ struct got_reference *ref, struct got_repository *repo,
+ got_ref_cmp_cb cmp_cb, void *cmp_arg);
+
/* Indicate whether the provided reference is symbolic (points at another
* refernce) or not (points at an object ID). */
int got_ref_is_symbolic(struct got_reference *);
blob - fcfc4cbf94642d9a6d37ac919bf5ba788dc7d9f8
blob + b89875ec9e861ec53c6a8c19a5fcbaa184ead648
--- lib/reference.c
+++ lib/reference.c
return err;
}
-static const struct got_error *
-insert_ref(struct got_reflist_entry **newp, struct got_reflist_head *refs,
+const struct got_error *
+got_reflist_insert(struct got_reflist_entry **newp, struct got_reflist_head *refs,
struct got_reference *ref, struct got_repository *repo,
got_ref_cmp_cb cmp_cb, void *cmp_arg)
{
goto done;
if (ref) {
struct got_reflist_entry *new;
- err = insert_ref(&new, refs, ref, repo,
+ err = got_reflist_insert(&new, refs, ref, repo,
cmp_cb, cmp_arg);
if (err || new == NULL /* duplicate */)
got_ref_close(ref);
err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0);
if (err)
goto done;
- err = insert_ref(&new, refs, ref, repo,
+ err = got_reflist_insert(&new, refs, ref, repo,
cmp_cb, cmp_arg);
if (err || new == NULL /* duplicate */)
got_ref_close(ref);
goto done;
/* Try to look up references in a given namespace. */
} else {
- err = insert_ref(&new, refs, ref, repo,
+ err = got_reflist_insert(&new, refs, ref, repo,
cmp_cb, cmp_arg);
if (err || new == NULL /* duplicate */)
got_ref_close(ref);
continue;
}
}
- err = insert_ref(&new, refs, ref, repo,
+ err = got_reflist_insert(&new, refs, ref, repo,
cmp_cb, cmp_arg);
if (err || new == NULL /* duplicate */)
got_ref_close(ref);
continue;
}
- err = insert_ref(&new, &refs, ref, repo,
+ err = got_reflist_insert(&new, &refs, ref, repo,
got_ref_cmp_by_name, NULL);
if (err || new == NULL /* duplicate */)
got_ref_close(ref);