commit-graph: split out function to search commit position
commit809ea28f809e52d3204b597637b2f5e072c140f8
authorPatrick Steinhardt <ps@pks.im>
Mon, 9 Aug 2021 08:11:59 +0000 (9 10:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Aug 2021 16:51:12 +0000 (9 09:51 -0700)
treeb80ce320ea84d371b686cfc331d4415f03bfe0d4
parentbf9c0cbddbcd730e4312ba5e19f8b8a2edd65bb3
commit-graph: split out function to search commit position

The function `find_commit_in_graph()` assumes that the caller has passed
an object which was already determined to be a commit given that it will
access the commit's graph position, which is stored in a commit slab. In
a subsequent patch, we want to search for an object ID though without
knowing whether it is a commit or not, which is not currently possible.

Split out the logic to search the commit graph for a given object ID to
prepare for this change. This commit also renames the function to
`find_commit_pos_in_graph()`, which more accurately reflects what this
function does. Furthermore, in order to allow for the searched object ID
to be const, we need to adjust `bsearch_graph()`'s signature to accept a
constant object ID as input, too.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c