]> git.ipfire.org Git - thirdparty/git.git/commit - sha1_name.c
get_short_sha1: refactor init of disambiguation code
authorJeff King <peff@peff.net>
Mon, 26 Sep 2016 12:00:04 +0000 (08:00 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Sep 2016 18:46:39 +0000 (11:46 -0700)
commit0016043bf46f4b85054c61f9000ccc58d0ef4ad7
tree070243d7f87b4c4ac9f93006f2c40c7138bee83b
parent5d5def2aa56dc9b6d4eccfb333fd08aa713733e7
get_short_sha1: refactor init of disambiguation code

The disambiguation machinery has two callers: get_short_sha1
and for_each_abbrev. Both need to repeat much of the same
setup: declaring buffers, sanity-checking lengths, preparing
the prefixes, etc.  Let's pull that into a single init
function so we can avoid repeating ourselves.

Pulling the buffers into the "struct disambiguate_state"
isn't strictly necessary, but it does make things simpler
for the callers, who no longer have to worry about sizing
them correctly (i.e., it's an implicit requirement that
the caller provide 20- and 40-byte buffers).

And while we're touching this code, we can convert any
magic-number sizes to the more modern GIT_SHA1_* constants.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c