Commit Diff


commit - 1963be61deb20cacab2552113c66b38fbee7a080
commit + 2f43cd698e3fcc3000262b3e0f3a2119f06345bb
blob - de09563aef39f346f9cf2c078c8dff429dc7bc4a
blob + 0421be7b0d2bf6778bac2fb8bdeabcd60fc89ad2
--- gitwrapper/Makefile
+++ gitwrapper/Makefile
@@ -10,8 +10,7 @@ BINDIR ?=	${PREFIX}/bin
 PROG=		gitwrapper
 
 SRCS=		gitwrapper.c parse.y log.c dial.c path.c error.c \
-		reference_parse.c hash.c object_parse.c imsg.c \
-		inflate.c pollfd.c
+		reference_parse.c hash.c object_qid.c
 
 CLEANFILES = parse.h
 
blob - a1a8e70bcff43bc951fef97bb37e60985bb35f76
blob + aaddaf72fdc7e84e4dbe9360dd6bd066d12b39d8
--- got/Makefile
+++ got/Makefile
@@ -16,7 +16,7 @@ SRCS=		got.c blame.c commit_graph.c delta.c diff.c \
 		bloom.c murmurhash2.c ratelimit.c patch.c sigs.c date.c \
 		object_open_privsep.c read_gitconfig_privsep.c \
 		read_gotconfig_privsep.c pack_create_privsep.c pollfd.c \
-		reference_parse.c
+		reference_parse.c object_qid.c
 
 MAN =		${PROG}.1 got-worktree.5 git-repository.5 got.conf.5
 
blob - cc4991565d1474d6bb048dff63d3db36b10e23c8
blob + 6e194139586ae1731a9aef3771d60596d3d0c756
--- gotadmin/Makefile
+++ gotadmin/Makefile
@@ -11,7 +11,7 @@ SRCS=		gotadmin.c \
 		worktree_open.c hash.c bloom.c murmurhash2.c ratelimit.c \
 		sigs.c buf.c date.c object_open_privsep.c \
 		read_gitconfig_privsep.c read_gotconfig_privsep.c \
-		pack_create_privsep.c pollfd.c reference_parse.c
+		pack_create_privsep.c pollfd.c reference_parse.c object_qid.c
 MAN =		${PROG}.1
 
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
blob - 6f68586c640662cd888e740dc5acaa83e889d438
blob + 61eb3c5d2c75ce1303a836e880c30e8394f98189
--- gotctl/Makefile
+++ gotctl/Makefile
@@ -3,7 +3,7 @@
 .include "../got-version.mk"
 
 PROG=		gotctl
-SRCS=		gotctl.c error.c imsg.c inflate.c object_parse.c path.c \
+SRCS=		gotctl.c error.c imsg.c object_qid.c path.c \
 		pollfd.c hash.c
 
 MAN =		${PROG}.8
blob - 3009e346a8d5ff1d82d8c7266688a122f425b807
blob + 57c307cbf240df2d50591814c9eb5e77bb24ae39
--- gotd/Makefile
+++ gotd/Makefile
@@ -15,7 +15,7 @@ SRCS=		gotd.c auth.c repo_read.c repo_write.c log.c pr
 		object_open_io.c object_parse.c opentemp.c pack.c path.c \
 		read_gitconfig.c read_gotconfig.c reference.c repository.c  \
 		hash.c sigs.c pack_create_io.c pollfd.c reference_parse.c \
-		repo_imsg.c pack_index.c session.c
+		repo_imsg.c pack_index.c session.c object_qid.c
 
 CLEANFILES = parse.h
 
blob - 764d96444519d4dfc13f888b5824e4c35e38e76f
blob + e181d09783d48cf8ca92d02f6f12aa9f0054a4f1
--- gotsh/Makefile
+++ gotsh/Makefile
@@ -4,8 +4,7 @@
 
 PROG=		gotsh
 SRCS=		gotsh.c error.c pkt.c hash.c serve.c path.c gitproto.c \
-		imsg.c inflate.c object_parse.c pollfd.c reference_parse.c \
-		dial.c
+		imsg.c pollfd.c dial.c reference_parse.c object_qid.c
 
 MAN =		${PROG}.1
 
blob - c2c364ff9f79098f7f41fb01b58642d7fa2661f9
blob + cc739de38d4839d70a3ad6d7034a837ff573bfb8
--- gotwebd/Makefile
+++ gotwebd/Makefile
@@ -20,7 +20,8 @@ SRCS +=		blame.c commit_graph.c delta.c diff.c \
 		diff_output_edscript.c diff_patience.c bloom.c murmurhash2.c \
 		worktree_open.c patch.c sigs.c date.c sockaddr.c \
 		object_open_privsep.c read_gitconfig_privsep.c \
-		read_gotconfig_privsep.c pollfd.c reference_parse.c
+		read_gotconfig_privsep.c pollfd.c reference_parse.c \
+		object_qid.c
 
 .if exists(${.CURDIR}/../template/obj/template)
 TEMPLATE = ${.CURDIR}/../template/obj/template
blob - 05240d53214a844ee3d7b7d988783c9e4cfd7147
blob + 9daacd33712bbd6a9ded56d7a03ed143ce6642d3
--- gotwebd/libexec/got-read-blob/Makefile
+++ gotwebd/libexec/got-read-blob/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-blob
 SRCS=		got-read-blob.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 1165c222b775505baa64d377371c136878c607c8
blob + f45137c3ce56dbaadeaf0a5f0ffffd3b4204668c
--- gotwebd/libexec/got-read-commit/Makefile
+++ gotwebd/libexec/got-read-commit/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-commit
 SRCS=		got-read-commit.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - e7bc462853862dcc5569354205b83cfa255442c1
blob + 44760613f030f1f1f62c831825d7bb85b07c9a46
--- gotwebd/libexec/got-read-gitconfig/Makefile
+++ gotwebd/libexec/got-read-gitconfig/Makefile
@@ -3,7 +3,8 @@
 
 PROG=		got-read-gitconfig
 SRCS=		got-read-gitconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c gitconfig.c pollfd.c
+		path.c privsep.c hash.c gitconfig.c pollfd.c \
+		object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - f148074e84910d2c34cba8f1bfe2985898b5d79a
blob + 26dec69ed1be0648baa16cabea96c54dc3731c54
--- gotwebd/libexec/got-read-gotconfig/Makefile
+++ gotwebd/libexec/got-read-gotconfig/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-gotconfig
 SRCS=		got-read-gotconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c parse.y pollfd.c
+		path.c privsep.c hash.c parse.y pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib \
 	-I${.CURDIR}/../../../libexec/got-read-gotconfig
blob - 97907ead0bd33b477aa7c06d62d666b9c00564ab
blob + 85841212056443f99c873f1089e3fef315ab7d2a
--- gotwebd/libexec/got-read-object/Makefile
+++ gotwebd/libexec/got-read-object/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-object
 SRCS=		got-read-object.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 12228b03188af547ebf7a86b8f434b966ed06b98
blob + 6ae7cd0c813fcc65f4256be6d06040df2d2880ba
--- gotwebd/libexec/got-read-pack/Makefile
+++ gotwebd/libexec/got-read-pack/Makefile
@@ -4,7 +4,7 @@
 PROG=		got-read-pack
 SRCS=		got-read-pack.c delta.c error.c inflate.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c pack.c path.c \
-		privsep.c hash.c delta_cache.c pollfd.c
+		privsep.c hash.c delta_cache.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - e3695245b3e0161a86859b3cb3e10a413f4d74bb
blob + eb7b682a069470aa6b445adfc142e1d7bdf7c4a4
--- gotwebd/libexec/got-read-tag/Makefile
+++ gotwebd/libexec/got-read-tag/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-tag
 SRCS=		got-read-tag.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - db849065b699533903ca1e34443e2612c1983ec8
blob + 497d2ff1cd06d53bcc607653bb658219cd8ea982
--- gotwebd/libexec/got-read-tree/Makefile
+++ gotwebd/libexec/got-read-tree/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-tree
 SRCS=		got-read-tree.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 46b6937a40c4a6e26bc8057ab744e6a55b88271c
blob + c3b2bdd9b1622256235092145718299216397766
--- lib/error.c
+++ lib/error.c
@@ -33,6 +33,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
+#include "got_lib_hash.h"
 #include "got_lib_object_parse.h"
 
 #ifndef nitems
blob - 1405a67ac335af59f8e1c2f04ac566ecd07436e7
blob + 88c77f6eb9da4d589aefd2ed3e9539327d379e53
--- lib/got_lib_hash.h
+++ lib/got_lib_hash.h
@@ -25,6 +25,14 @@ char *got_sha1_digest_to_str(const uint8_t *, char *, 
 char *got_sha256_digest_to_str(const uint8_t *, char *, size_t);
 
 int got_parse_hash_digest(uint8_t *, const char *, enum got_hash_algorithm);
+
+/*
+ * Write the string representation fo an object ID in the given buffer.
+ * This buffer must be at least GOT_OBJECT_ID_HEX_MAXLEN bytes in size.
+ * The output depneds on the hash function used by the repository format.
+ */
+char *got_object_id_hex(struct got_object_id *, char *, size_t);
+
 int got_parse_object_id(struct got_object_id *, const char *,
     enum got_hash_algorithm);
 
blob - 767c404755f278059ea3f7b3890ee3a3d0188974
blob + e0d04d5ded1ba4a6804afe49bf9df83eda5d2250
--- lib/got_lib_object_parse.h
+++ lib/got_lib_object_parse.h
@@ -16,16 +16,8 @@
 
 struct got_pathlist_head;
 
-/*
- * Write the string representation fo an object ID in the given buffer.
- * This buffer must be at least GOT_OBJECT_ID_HEX_MAXLEN bytes in size.
- * The output depneds on the hash function used by the repository format.
- */
-char *got_object_id_hex(struct got_object_id *, char *, size_t);
-
 const struct got_error *got_object_type_label(const char **, int);
 
-const struct got_error *got_object_qid_alloc_partial(struct got_object_qid **);
 struct got_commit_object *got_object_commit_alloc_partial(void);
 struct got_tree_entry *got_alloc_tree_entry_partial(void);
 
blob - /dev/null
blob + 3da5974aee776a379af798d1bc6dcf8f93085579 (mode 644)
--- /dev/null
+++ lib/got_lib_object_qid.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2018, 2019, 2020, 2023 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+const struct got_error *got_object_qid_alloc_partial(struct got_object_qid **);
blob - 0d02c860eaa1b48dbfe675e8d6987396d3a1ff21
blob + 20b361d7668e783af7ab8170c7386a21faf20307
--- lib/hash.c
+++ lib/hash.c
@@ -26,10 +26,48 @@
 #include <limits.h>
 
 #include "got_object.h"
+#include "got_error.h"
 
 #include "got_lib_hash.h"
 
+struct got_object_id *
+got_object_id_dup(struct got_object_id *id1)
+{
+	struct got_object_id *id2;
+
+	id2 = malloc(sizeof(*id2));
+	if (id2 == NULL)
+		return NULL;
+	memcpy(id2, id1, sizeof(*id2));
+	return id2;
+}
+
 int
+got_object_id_cmp(const struct got_object_id *id1,
+    const struct got_object_id *id2)
+{
+	return memcmp(id1->sha1, id2->sha1, SHA1_DIGEST_LENGTH);
+}
+
+const struct got_error *
+got_object_id_str(char **outbuf, struct got_object_id *id)
+{
+	static const size_t len = GOT_OBJECT_ID_HEX_MAXLEN;
+
+	*outbuf = malloc(len);
+	if (*outbuf == NULL)
+		return got_error_from_errno("malloc");
+
+	if (got_object_id_hex(id, *outbuf, len) == NULL) {
+		free(*outbuf);
+		*outbuf = NULL;
+		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+	}
+
+	return NULL;
+}
+
+int
 got_parse_xdigit(uint8_t *val, const char *hex)
 {
 	char *ep;
@@ -114,6 +152,12 @@ got_parse_hash_digest(uint8_t *digest, const char *lin
 	}
 }
 
+char *
+got_object_id_hex(struct got_object_id *id, char *buf, size_t len)
+{
+	return got_sha1_digest_to_str(id->sha1, buf, len);
+}
+
 int
 got_parse_object_id(struct got_object_id *id, const char *line,
     enum got_hash_algorithm algo)
blob - 8c8a840aeee11db19adfe359200c154280b12be0
blob + 2e12a69bb09622ca93b1e6240e2f9d4b5f204a91
--- lib/object.c
+++ lib/object.c
@@ -176,41 +176,6 @@ got_object_resolve_id_str(struct got_object_id **id,
 	return NULL;
 }
 
-const struct got_error *
-got_object_qid_alloc(struct got_object_qid **qid, struct got_object_id *id)
-{
-	*qid = calloc(1, sizeof(**qid));
-	if (*qid == NULL)
-		return got_error_from_errno("calloc");
-
-	memcpy(&(*qid)->id, id, sizeof((*qid)->id));
-	return NULL;
-}
-
-const struct got_error *
-got_object_id_queue_copy(const struct got_object_id_queue *src,
-    struct got_object_id_queue *dest)
-{
-	const struct got_error *err;
-	struct got_object_qid *qid;
-
-	STAILQ_FOREACH(qid, src, entry) {
-		struct got_object_qid *new;
-		/*
-		 * Deep-copy the object ID only. Let the caller deal
-		 * with setting up the new->data pointer if needed.
-		 */
-		err = got_object_qid_alloc(&new, &qid->id);
-		if (err) {
-			got_object_id_queue_free(dest);
-			return err;
-		}
-		STAILQ_INSERT_TAIL(dest, new, entry);
-	}
-
-	return NULL;
-}
-
 int
 got_object_tree_get_nentries(struct got_tree_object *tree)
 {
blob - 103067d7de3a1d7703e09e80cf6385c016733b27
blob + d74774dae3cba161ec98655b4c81d2d9fb38693c
--- lib/object_idset.c
+++ lib/object_idset.c
@@ -34,6 +34,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_object_idset.h"
 #include "got_lib_object_parse.h"
 
blob - 831119712bcf2cd3955126858b0726abcb140445
blob + b5229cd68c12aaa23558c7fd20e171ae4aed35ce
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -48,6 +48,7 @@
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_pack.h"
 #include "got_lib_repository.h"
@@ -56,61 +57,7 @@
 #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
 #endif
 
-struct got_object_id *
-got_object_id_dup(struct got_object_id *id1)
-{
-	struct got_object_id *id2;
-
-	id2 = malloc(sizeof(*id2));
-	if (id2 == NULL)
-		return NULL;
-	memcpy(id2, id1, sizeof(*id2));
-	return id2;
-}
-
-int
-got_object_id_cmp(const struct got_object_id *id1,
-    const struct got_object_id *id2)
-{
-	return memcmp(id1->sha1, id2->sha1, SHA1_DIGEST_LENGTH);
-}
-
 const struct got_error *
-got_object_qid_alloc_partial(struct got_object_qid **qid)
-{
-	*qid = malloc(sizeof(**qid));
-	if (*qid == NULL)
-		return got_error_from_errno("malloc");
-
-	(*qid)->data = NULL;
-	return NULL;
-}
-
-const struct got_error *
-got_object_id_str(char **outbuf, struct got_object_id *id)
-{
-	static const size_t len = GOT_OBJECT_ID_HEX_MAXLEN;
-
-	*outbuf = malloc(len);
-	if (*outbuf == NULL)
-		return got_error_from_errno("malloc");
-
-	if (got_object_id_hex(id, *outbuf, len) == NULL) {
-		free(*outbuf);
-		*outbuf = NULL;
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
-	}
-
-	return NULL;
-}
-
-char *
-got_object_id_hex(struct got_object_id *id, char *buf, size_t len)
-{
-	return got_sha1_digest_to_str(id->sha1, buf, len);
-}
-
-const struct got_error *
 got_object_type_label(const char **label, int obj_type)
 {
 	const struct got_error *err = NULL;
@@ -185,24 +132,6 @@ got_object_raw_close(struct got_raw_object *obj)
 	}
 	free(obj);
 	return err;
-}
-
-void
-got_object_qid_free(struct got_object_qid *qid)
-{
-	free(qid);
-}
-
-void
-got_object_id_queue_free(struct got_object_id_queue *ids)
-{
-	struct got_object_qid *qid;
-
-	while (!STAILQ_EMPTY(ids)) {
-		qid = STAILQ_FIRST(ids);
-		STAILQ_REMOVE_HEAD(ids, entry);
-		got_object_qid_free(qid);
-	}
 }
 
 const struct got_error *
blob - 5c336264de3d25587a6e025ec8a194157b047cb4
blob + a9b71c809585eb6a270c9f49e602be196d76f3ad
--- lib/pack.c
+++ lib/pack.c
@@ -45,6 +45,7 @@
 #include "got_lib_delta_cache.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_privsep.h"
 #include "got_lib_pack.h"
blob - /dev/null
blob + e4574472a88375bfac44ed049b2e5050ad77a389 (mode 644)
--- /dev/null
+++ lib/object_qid.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2018, 2019, 2020, 2023 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/queue.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sha1.h>
+#include <sha2.h>
+
+#include "got_object.h"
+#include "got_error.h"
+
+#include "got_lib_object_qid.h"
+#include "got_lib_hash.h"
+
+const struct got_error *
+got_object_qid_alloc_partial(struct got_object_qid **qid)
+{
+	*qid = malloc(sizeof(**qid));
+	if (*qid == NULL)
+		return got_error_from_errno("malloc");
+
+	(*qid)->data = NULL;
+	return NULL;
+}
+
+const struct got_error *
+got_object_qid_alloc(struct got_object_qid **qid, struct got_object_id *id)
+{
+	*qid = calloc(1, sizeof(**qid));
+	if (*qid == NULL)
+		return got_error_from_errno("calloc");
+
+	memcpy(&(*qid)->id, id, sizeof((*qid)->id));
+	return NULL;
+}
+
+void
+got_object_qid_free(struct got_object_qid *qid)
+{
+	free(qid);
+}
+
+void
+got_object_id_queue_free(struct got_object_id_queue *ids)
+{
+	struct got_object_qid *qid;
+
+	while (!STAILQ_EMPTY(ids)) {
+		qid = STAILQ_FIRST(ids);
+		STAILQ_REMOVE_HEAD(ids, entry);
+		got_object_qid_free(qid);
+	}
+}
+
+const struct got_error *
+got_object_id_queue_copy(const struct got_object_id_queue *src,
+    struct got_object_id_queue *dest)
+{
+	const struct got_error *err;
+	struct got_object_qid *qid;
+
+	STAILQ_FOREACH(qid, src, entry) {
+		struct got_object_qid *new;
+		/*
+		 * Deep-copy the object ID only. Let the caller deal
+		 * with setting up the new->data pointer if needed.
+		 */
+		err = got_object_qid_alloc(&new, &qid->id);
+		if (err) {
+			got_object_id_queue_free(dest);
+			return err;
+		}
+		STAILQ_INSERT_TAIL(dest, new, entry);
+	}
+
+	return NULL;
+}
blob - cfa0e0b64748e7fbb205cd975b92dc071f1a7510
blob + fa491359e992063082c4f94ac5629e4aed89ac29
--- lib/privsep.c
+++ lib/privsep.c
@@ -45,6 +45,7 @@
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_privsep.h"
 #include "got_lib_pack.h"
 #include "got_lib_poll.h"
blob - ae942231a4113ed60cf12a3cd075564ca02dd988
blob + 83d9bdd52d2b584f435975f4214f2892f2002cf1
--- libexec/got-fetch-pack/Makefile
+++ libexec/got-fetch-pack/Makefile
@@ -5,7 +5,7 @@
 PROG=		got-fetch-pack
 SRCS=		got-fetch-pack.c error.c inflate.c object_parse.c \
 		path.c privsep.c hash.c pkt.c gitproto.c ratelimit.c \
-		pollfd.c
+		pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 92a354326a20f1fee1023a18f5b058b069586c0a
blob + 23a76d326b94bf821ef26e61601adb4ca06ac25d
--- libexec/got-index-pack/Makefile
+++ libexec/got-index-pack/Makefile
@@ -5,7 +5,7 @@
 PROG=		got-index-pack
 SRCS=		got-index-pack.c error.c inflate.c object_parse.c object_idset.c \
 		delta_cache.c delta.c pack.c path.c privsep.c hash.c ratelimit.c \
-		pack_index.c pollfd.c
+		pack_index.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 8b366057440af8a415007747940c3f85474583a3
blob + 9d814fc7b44d62a6a31880c030beba561c834ba0
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
@@ -38,6 +38,7 @@
 #include "got_lib_delta_cache.h"
 #include "got_lib_hash.h"
 #include "got_lib_object.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_privsep.h"
 #include "got_lib_ratelimit.h"
 #include "got_lib_pack.h"
blob - 23ce4ec071efb8c72e90c5c8eca304ea20056375
blob + 2fd8132cf951fde1e7076a8b08706af21d15e303
--- libexec/got-read-blob/Makefile
+++ libexec/got-read-blob/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-blob
 SRCS=		got-read-blob.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		object_qid.c path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - f13607515ea61ff5d111d7206363d56b58d23aa3
blob + c63094934cc15a15a212d7dd509d0bca445fc20c
--- libexec/got-read-commit/Makefile
+++ libexec/got-read-commit/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-commit
 SRCS=		got-read-commit.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		object_qid.c path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 0d5a81cd2be10724bfca5d40fe59053215b749e3
blob + 349ab039f60b6ca3745866df6ab52257ed03fd1b
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
@@ -38,6 +38,7 @@
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_privsep.h"
 #include "got_lib_hash.h"
 
blob - 5aa516cfcc8b0ad54ab77d31ee508cf18811d3e4
blob + add7686129fe4d9085d129fb525b97383acae649
--- libexec/got-read-gitconfig/Makefile
+++ libexec/got-read-gitconfig/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-gitconfig
 SRCS=		got-read-gitconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c gitconfig.c pollfd.c
+		path.c privsep.c hash.c gitconfig.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 044ef784dc31510af95cba76b60908fe505a9eae
blob + 63e27e448efdd9fba92f350a9d9335a1e9806660
--- libexec/got-read-gotconfig/Makefile
+++ libexec/got-read-gotconfig/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-gotconfig
 SRCS=		got-read-gotconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c parse.y pollfd.c
+		path.c privsep.c hash.c parse.y pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib -I${.CURDIR}
 YFLAGS =
blob - 73b38413ebe7843e58920f98b259e1505bf4b1f5
blob + 1fe18abf9d8ca1a5d3666e7efdbb4b9e980f6b3f
--- libexec/got-read-object/Makefile
+++ libexec/got-read-object/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-object
 SRCS=		got-read-object.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		object_qid.c path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 23067a70e47387cb0d2dc4cbafc14e62e542a662
blob + 71f4c093cb5592f636e0e7b6156fc8f15e61d198
--- libexec/got-read-pack/Makefile
+++ libexec/got-read-pack/Makefile
@@ -5,7 +5,7 @@
 PROG=		got-read-pack
 SRCS=		got-read-pack.c delta.c error.c inflate.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c pack.c path.c \
-		privsep.c hash.c delta_cache.c pollfd.c
+		privsep.c hash.c delta_cache.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 62e4cf4d156d8e4fbbc26a8f1d65893a5da67f2b
blob + 1ff3707be9bef771b3d4084997853ada44c722ac
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -41,6 +41,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_delta_cache.h"
 #include "got_lib_object.h"
+#include "got_lib_object_qid.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_object_idset.h"
blob - a9a8b307200d2da9499202b060147e7f7933d122
blob + 3f823ad5c4c22b6f9696f1956e218ee4c2c38fcf
--- libexec/got-read-patch/Makefile
+++ libexec/got-read-patch/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-patch
 SRCS=		got-read-patch.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		path.c privsep.c hash.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - e8e772933d6d6a5e5df33d1a2339dd897f353b1b
blob + dbb2b88b9ea9cbea01e03483ea760114bf3f1158
--- libexec/got-read-tag/Makefile
+++ libexec/got-read-tag/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-tag
 SRCS=		got-read-tag.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		object_qid.c path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 17c93154615fbf085466a3685f96d9058b259ec9
blob + e96a0cfb7fe0895322bb8f3d9adb339cfc9028b2
--- libexec/got-read-tree/Makefile
+++ libexec/got-read-tree/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-tree
 SRCS=		got-read-tree.c error.c inflate.c object_parse.c \
-		path.c privsep.c hash.c pollfd.c
+		object_qid.c path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - ab90d8b29f892ebe8290f3c9234bd433093bd865
blob + 0ee7f48e9798394f8c0c4cb76159344d5d4c1bb0
--- libexec/got-send-pack/Makefile
+++ libexec/got-send-pack/Makefile
@@ -5,7 +5,7 @@
 PROG=		got-send-pack
 SRCS=		got-send-pack.c error.c inflate.c object_parse.c \
 		path.c privsep.c hash.c pkt.c gitproto.c ratelimit.c \
-		pollfd.c reference_parse.c
+		pollfd.c reference_parse.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 475dd4289d617e4ccfde05e7dd965aadacae6aff
blob + 45aa930f4a42d5bb431534bef25ce8c8b73c2944
--- regress/delta/Makefile
+++ regress/delta/Makefile
@@ -2,7 +2,7 @@
 
 PROG = delta_test
 SRCS = delta.c error.c opentemp.c path.c inflate.c hash.c delta_test.c \
-	pollfd.c object_parse.c
+	pollfd.c object_parse.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lz
blob - c89d76ee9c4539c7d7c3907089ab2b233a8744a2
blob + f842e2c2c6f4297790ef648c442b81054653f1cb
--- regress/deltify/Makefile
+++ regress/deltify/Makefile
@@ -2,7 +2,7 @@
 
 PROG = deltify_test
 SRCS = deltify.c error.c opentemp.c hash.c deltify_test.c murmurhash2.c \
-	object_parse.c inflate.c path.c pollfd.c
+	object_parse.c inflate.c path.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lz
blob - 4c3c7abb0a9b0de487050e9bc9149cb0d46f9749
blob + 5226e9385a97d432d2d5b872248237c615ba1f26
--- regress/fetch/Makefile
+++ regress/fetch/Makefile
@@ -6,7 +6,7 @@ SRCS = error.c privsep.c reference.c hash.c object.c o
 	deflate.c delta.c delta_cache.c object_idset.c object_create.c \
 	fetch.c gotconfig.c dial.c fetch_test.c bloom.c murmurhash2.c sigs.c \
 	buf.c date.c object_open_privsep.c read_gitconfig_privsep.c \
-	read_gotconfig_privsep.c pollfd.c reference_parse.c
+	read_gotconfig_privsep.c pollfd.c reference_parse.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz -lm
blob - 6b78a4717b9682af0793283e080f4458ab6a8b8e
blob + 57a49d224d6446e0fd67a0b5e72a31608b40be31
--- regress/idset/Makefile
+++ regress/idset/Makefile
@@ -2,7 +2,7 @@
 
 PROG = idset_test
 SRCS = error.c hash.c object_idset.c inflate.c path.c object_parse.c \
-	idset_test.c pollfd.c
+	idset_test.c pollfd.c object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
blob - 23a916db855dd46d0844a60ae1b609c2e9c37279
blob + 54b4f76a6f8bc2e2a14de909de4e7aced350c5d9
--- regress/path/Makefile
+++ regress/path/Makefile
@@ -1,7 +1,8 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = path_test
-SRCS = error.c path.c hash.c path_test.c object_parse.c inflate.c pollfd.c
+SRCS = error.c path.c hash.c path_test.c object_parse.c inflate.c pollfd.c \
+	object_qid.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
blob - 246c94d7499f25bf057c19817889f00c83453008
blob + 1e04e11c8366de402f81cecbd2da54e48dd11a27
--- tog/Makefile
+++ tog/Makefile
@@ -14,7 +14,8 @@ SRCS=		tog.c blame.c commit_graph.c delta.c diff.c \
 		diff_output_unidiff.c diff_output_edscript.c \
 		diff_patience.c bloom.c murmurhash2.c sigs.c date.c \
 		object_open_privsep.c read_gitconfig_privsep.c \
-		read_gotconfig_privsep.c pollfd.c reference_parse.c
+		read_gotconfig_privsep.c pollfd.c reference_parse.c \
+		object_qid.c
 MAN =		${PROG}.1
 
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib