Commit 6e72e6a3bf1fd0e9a976114e25c7aad6b22587b0

Stefan Sperling 2018-12-23T23:21:35

there's no point in embedding the object header in commits

diff --git a/lib/got_lib_object.h b/lib/got_lib_object.h
index c3257cf..14bd628 100644
--- a/lib/got_lib_object.h
+++ b/lib/got_lib_object.h
@@ -37,7 +37,6 @@ struct got_object {
 };
 
 struct got_commit_object {
-	struct got_object *obj;
 	struct got_object_id *tree_id;
 	unsigned int nparents;
 	struct got_object_id_queue parent_ids;
diff --git a/lib/object.c b/lib/object.c
index 41e5235..0406a8a 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1171,25 +1171,6 @@ done:
 }
 
 static const struct got_error *
-receive_commit(struct got_commit_object **commit, struct imsgbuf *ibuf)
-{
-	const struct got_error *err = NULL;
-	struct got_object *obj;
-
-	err = got_privsep_recv_obj(&obj, ibuf);
-	if (err)
-		return err;
-
-	err = got_privsep_recv_commit(commit, ibuf);
-	if (err)
-		got_object_close(obj);
-	else
-		(*commit)->obj = obj; /* XXX should be embedded */
-
-	return err;
-}
-
-static const struct got_error *
 request_commit(struct got_commit_object **commit, struct got_repository *repo,
     int fd)
 {
@@ -1202,7 +1183,7 @@ request_commit(struct got_commit_object **commit, struct got_repository *repo,
 	if (err)
 		return err;
 
-	return receive_commit(commit, ibuf);
+	return got_privsep_recv_commit(commit, ibuf);
 }
 
 static const struct got_error *
@@ -1216,7 +1197,7 @@ request_packed_commit(struct got_commit_object **commit, struct got_pack *pack,
 	if (err)
 		return err;
 
-	return receive_commit(commit, pack->privsep_child->ibuf);
+	return got_privsep_recv_commit(commit, pack->privsep_child->ibuf);
 }
 
 const struct got_error *
diff --git a/lib/object_parse.c b/lib/object_parse.c
index b98b178..f764c90 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -377,7 +377,6 @@ got_object_commit_close(struct got_commit_object *commit)
 	free(commit->author);
 	free(commit->committer);
 	free(commit->logmsg);
-	got_object_close(commit->obj);
 	free(commit);
 }
 
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index eeafefc..c7431a4 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -78,11 +78,7 @@ read_commit_object(struct got_commit_object **commit, FILE *f)
 	err = got_object_parse_commit(commit, p + obj->hdrlen, len);
 done:
 	free(p);
-	if (err)
-		got_object_close(obj);
-	else
-		(*commit)->obj = obj; /* XXX should be embedded in struct */
-
+	got_object_close(obj);
 	return err;
 }
 
@@ -146,13 +142,6 @@ main(int argc, char *argv[])
 		if (err)
 			goto done;
 
-		/* XXX This flushes the pipe, should only fill it instead. */
-		err = got_privsep_send_obj(&ibuf, commit->obj);
-		if (err)
-			goto done;
-
-		/* XXX Assumes full imsg buf size, should take obj into
-		 * account when above flush is removed. */
 		err = got_privsep_send_commit(&ibuf, commit);
 done:
 		if (f)
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 9222733..8d243d0 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -149,18 +149,8 @@ commit_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
 	if (err) {
 		got_object_close(obj);
 		return err;
-	} else
-		commit->obj = obj; /* XXX should be embedded */
-
-	/* XXX This flushes the pipe, should only fill it instead. */
-	err = got_privsep_send_obj(ibuf, commit->obj);
-	if (err) {
-		got_object_commit_close(commit);
-		return err;
 	}
 
-	/* XXX Assumes full imsg buf size, should take obj into
-	 * account when above flush is removed. */
 	err = got_privsep_send_commit(ibuf, commit);
 	got_object_commit_close(commit);
 	if (err) {