"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: fix 'gotadmin pack' when only tags are given
To:
gameoftrees@openbsd.org
Date:
Sun, 29 Aug 2021 16:38:22 +0200

Download raw body.

Thread
Stefan Sperling:

> Fix 'gotadmin pack' not packing any objects if all arguments are tags.

Those "return err" in the changes and context should be "goto done".

The "GOT_OBJ_TYPE_TAG" and "else" branches perform the same actions.
Would it be clearer to let the "GOT_OBJ_TYPE_TAG" code fall through?
Like this:

diff 535e07c7d678cfc4a2b6ad61f72c36e0a46e5111 /home/naddy/got
blob - 1455b6df378eb19d397ce2e3d3588af5a0256490
file + lib/pack_create.c
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -527,9 +527,10 @@ load_tag(struct got_pack_metavec *v, struct got_object
 
 	switch (got_object_tag_get_object_type(tag)) {
 	case GOT_OBJ_TYPE_COMMIT:
-		err = load_commit(NULL, idset,
-		    got_object_tag_get_object_id(tag), repo,
-		    loose_obj_only, cancel_cb, cancel_arg);
+		/*
+		 * Commits should already be loaded since findtwixt()
+		 * adds them to the object ID list.
+		 */
 		break;
 	case GOT_OBJ_TYPE_TREE:
 		err = load_tree(v, idset, got_object_tag_get_object_id(tag),
@@ -688,7 +689,16 @@ findtwixt(struct got_object_id ***res, int *nres,
 			continue;
 		err = got_object_get_type(&obj_type, repo, id);
 		if (err)
-			return err;
+			goto done;
+		if (obj_type == GOT_OBJ_TYPE_TAG) {
+			struct got_tag_object *tag;
+			err = got_object_open_as_tag(&tag, repo, id);
+			if (err)
+				goto done;
+			obj_type = got_object_tag_get_object_type(tag);
+			id = got_object_tag_get_object_id(tag);
+			got_object_tag_close(tag);
+		}
 		if (obj_type != GOT_OBJ_TYPE_COMMIT)
 			continue;
 		err = queue_commit_id(&ids, id, COLOR_KEEP, repo);
@@ -701,7 +711,16 @@ findtwixt(struct got_object_id ***res, int *nres,
 			continue;
 		err = got_object_get_type(&obj_type, repo, id);
 		if (err)
-			return err;
+			goto done;
+		if (obj_type == GOT_OBJ_TYPE_TAG) {
+			struct got_tag_object *tag;
+			err = got_object_open_as_tag(&tag, repo, id);
+			if (err)
+				goto done;
+			obj_type = got_object_tag_get_object_type(tag);
+			id = got_object_tag_get_object_id(tag);
+			got_object_tag_close(tag);
+		}
 		if (obj_type != GOT_OBJ_TYPE_COMMIT)
 			continue;
 		err = queue_commit_id(&ids, id, COLOR_DROP, repo);
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de