summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-09-26 11:59:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-26 18:46:30 (GMT)
commit5d5def2aa56dc9b6d4eccfb333fd08aa713733e7 (patch)
tree61636febb07a64389941604c109e72958a022d9b /sha1_name.c
parent8a10fea49b1f95daeea445072a60139590b216cf (diff)
downloadgit-5d5def2aa56dc9b6d4eccfb333fd08aa713733e7.zip
git-5d5def2aa56dc9b6d4eccfb333fd08aa713733e7.tar.gz
git-5d5def2aa56dc9b6d4eccfb333fd08aa713733e7.tar.bz2
get_short_sha1: parse tags when looking for treeish
The treeish disambiguation function tries to peel tags, but it does so by calling: deref_tag(lookup_object(sha1), ...); This will only work if we have previously looked at the tag and created a "struct tag" for it. Since parsing revision arguments typically happens before anything else, this is usually not the case, and we would fail to peel the tag (we are lucky that deref_tag() gracefully handles the NULL and does not segfault). Instead, we can use parse_object(). Note that this is the same fix done by 94d75d1 (get_short_sha1(): correctly disambiguate type-limited abbreviation, 2013-07-01), but that commit fixed only the committish disambiguator, and left the bug in the treeish one. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 9356ac2..6636504 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -269,7 +269,7 @@ static int disambiguate_treeish_only(const unsigned char *sha1, void *cb_data_un
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_TREE || obj->type == OBJ_COMMIT))
return 1;
return 0;