]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-name.c
sha1_name.c: restructure disambiguation of short names
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 Jun 2012 05:07:36 +0000 (22:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jul 2012 17:24:15 +0000 (10:24 -0700)
commita78fafe74a4f8c416c35ca07b3ba28375475ae96
treecab44a37f603cd8c67f7a8a0a0b14d2595f6d996
parent1703f9aa0b87d52278489029d538ef1a4aa37432
sha1_name.c: restructure disambiguation of short names

We try to find zero, one or more matches from loose objects and
packed objects independently and then decide if the given short
object name is unique across them.

Instead, introduce a "struct disambiguate_state" that keeps track of
what we have found so far, that can be one of:

 - We have seen one object that _could_ be what we are looking for;
 - We have also checked that object for additional constraints (if any),
   and found that the object satisfies it;
 - We have also checked that object for additional constraints (if any),
   and found that the object does not satisfy it; or
 - We have seen more than one objects that satisfy the constraints.

and pass it to the enumeration functions for loose and packed
objects.  The disambiguation state can optionally take a callback
function that takes a candidate object name and reports if the
object satisifies additional criteria (e.g. when the caller knows
that the short name must refer to a commit, this mechanism can be
used to check the type of the given object).

Compared to the earlier attempt, this round avoids the optional
check if there is only one candidate that matches the short name in
the first place.

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