diff mbox series

[v2,4/8] commit-graph: use obj->type, not object_as_type()

Message ID patch-4.8-8e43d44911-20210420T133218Z-avarab@gmail.com (mailing list archive)
State New
Headers show
Series object.c: add and use "is expected" utility function + object_as_type() use | expand

Commit Message

Ævar Arnfjörð Bjarmason April 20, 2021, 1:36 p.m. UTC
Change a check of a deref_tag() return value to just use obj->type
instead of object_as_type(). The object_as_type() function is for
low-level use by fsck, {commit,tree,blob,tag}.c and the like, here we
can just assume the object is fully initialized.

As can be seen in plenty of existing uses in our codebase the return
value of deref_tag() won't be an obj->type == OBJ_NONE or
!obj->parsed. Fixes code added in 2f00c355cb7 (commit-graph: drop

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 builtin/commit-graph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index cd86315221..347d65abc8 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -158,7 +158,7 @@  static int read_one_commit(struct oidset *commits, struct progress *progress,
 			   NULL, 0);
 	if (!result)
 		return error(_("invalid object: %s"), hash);
-	else if (object_as_type(result, OBJ_COMMIT, 1))
+	else if (result->type == OBJ_COMMIT)
 		oidset_insert(commits, &result->oid);
 	display_progress(progress, oidset_size(commits));