refs/packed-backend.c: refactor `find_reference_location()`
commitd22d941ac08aa31266bb0b38d78c79c3ffdc4f86
authorTaylor Blau <me@ttaylorr.com>
Mon, 10 Jul 2023 21:12:25 +0000 (10 17:12 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2023 21:48:55 +0000 (10 14:48 -0700)
tree6a49408e7aa9f94c0cf20bdfb9aae5c5949c4702
parentb269ac53c07aa46d5a88d05dac8216d189e69a50
refs/packed-backend.c: refactor `find_reference_location()`

The function `find_reference_location()` is used to perform a
binary search-like function over the contents of a repository's
`$GIT_DIR/packed-refs` file.

The search it implements is unlike a standard binary search in that the
records it searches over are not of a fixed width, so the comparison
must locate the end of a record before comparing it.

Extract the core routine of `find_reference_location()` in order to
implement a function in the following patch which will find the first
location in the `packed-refs` file that *doesn't* match the given
pattern.

The behavior of `find_reference_location()` is unchanged.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/packed-backend.c