diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-07-01 21:54:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-01 21:54:45 -0700 |
commit | 94d75d1ed5c03b3c0191221f8e3960d808ba7e23 (patch) | |
tree | b8c179d1948023acbb5f5a3ea334d34f4b2d2823 /sha1_name.c | |
parent | 2c57f7c9a2ae0190c0abe050197f2da6b56ef414 (diff) | |
download | git-94d75d1ed5c03b3c0191221f8e3960d808ba7e23.tar.gz git-94d75d1ed5c03b3c0191221f8e3960d808ba7e23.tar.xz |
get_short_sha1(): correctly disambiguate type-limited abbreviation
One test in t1512 that expects a failure incorrectly passed. The
test prepares a commit whose object name begins with ten "0"s, and
also prepares a tag that points at the commit. The object name of
the tag also begins with ten "0"s. There is no other commit-ish
object in the repository whose name begins with such a prefix.
Ideally, in such a repository:
$ git rev-parse --verify 0000000000^{commit}
should yield that commit. If 0000000000 is taken as the commit
0000000000e4f, peeling it to a commmit yields that commit itself,
and if 0000000000 is taken as the tag 0000000000f8f, peeling it to a
commit also yields the same commit, so in that twisted sense, the
extended SHA-1 expression 0000000000^{commit} is unambigous. The
test that expects a failure is to check the above command.
The reason the test expects a failure is that we did not implement
such a "unification" of two candidate objects. What we did (or at
least, meant to) implement was to recognise that a commit-ish is
required to expand 0000000000, and notice that there are two succh
commit-ish, and diagnose the request as ambiguous.
However, there was a bug in the logic to check the candidate
objects. When the code saw 0000000000f8f (a tag) that shared the
shortened prefix (ten "0"s), it tried to make sure that the tag is a
commit-ish by looking at the tag object. Because it incorrectly
used lookup_object() when the tag has not been parsed, however, we
incorrectly declared that the tag is _not_ a commit-ish, leaving the
sole commit in the repository, 0000000000e4f, that has the required
prefix as "unique match", causing the test to pass when it shouldn't.
This fixes the logic to inspect the type of the object a tag refers
to, to make the test that is expected to fail correctly fail.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c index 8bc20c54b..13c3d75e8 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -241,7 +241,7 @@ static int disambiguate_committish_only(const unsigned char *sha1, void *cb_data return 0; /* We need to do this the hard way... */ - obj = deref_tag(lookup_object(sha1), NULL, 0); + obj = deref_tag(parse_object(sha1), NULL, 0); if (obj && obj->type == OBJ_COMMIT) return 1; return 0; |