[PATCH v2 4/8] commit-graph: use obj->type, not object_as_type()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 20, 2021, 13:36 UTC
- Message-ID
- <patch-4.8-8e43d44911-20210420T133218Z-avarab@gmail.com>
- In-Reply-To
- <cover-0.8-0000000000-20210420T133218Z-avarab@gmail.com>
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 COMMIT_GRAPH_WRITE_CHECK_OIDS flag, 2020-05-13).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- builtin/commit-graph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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));
-- 2.31.1.723.ga5d7868e4a