From 81234673a1f7cd5d92f0dd5f03d1442ec1ed2d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 5 Apr 2011 16:53:32 +0200 Subject: [PATCH] tag: discover the target type if needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't blindly pass the target type to git_tag_type2string as it will give an empty string on GIT_OBJ_ANY which would cause us to create an invalid tag object. Signed-off-by: Carlos Martín Nieto --- src/tag.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tag.c b/src/tag.c index ef58e0982..994389c9d 100644 --- a/src/tag.c +++ b/src/tag.c @@ -209,6 +209,14 @@ static int tag_create( return error; } + /* Try to find out what the type is */ + if (target_type == GIT_OBJ_ANY) { + size_t _unused; + error = git_odb_read_header(&_unused, &target_type, repo->db, target); + if (error < GIT_SUCCESS) + return error; + } + type_str = git_object_type2string(target_type); tagger_str_len = git_signature__write(&tagger_str, "tagger", tagger);