Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/tag.c
diff options
context:
space:
mode:
authorErik van Zijst <erik.van.zijst@gmail.com>2012-11-02 21:28:17 +0400
committerErik van Zijst <erik.van.zijst@gmail.com>2012-11-02 21:28:17 +0400
commit6bb9fea13ee2da6475ac799acd5f8296bc1a8537 (patch)
treed9947d87d5f11136993cc4cf08c3ea00897329dc /src/tag.c
parente30c052c4e46df9d8f929ab4f86f34718bb15a5d (diff)
tags: Fixed the tag parser to correctly treat the message field as optional.
This fix makes libgit2 capable of parsing annotated tag objects that lack the optional message/description field. Previously, libgit2 treated this field as mandatory and raised a tag_error on such tags. However, the message field is optional. An example of such a tag is refs/tags/v2.6.16.31-rc1 in Linux: $ git cat-file tag refs/tags/v2.6.16.31-rc1 object afaa018cefb6af63befef1df7d8febaae904434f type commit tag v2.6.16.31-rc1 tagger Adrian Bunk <bunk@stusta.de> 1162716505 +0100 $
Diffstat (limited to 'src/tag.c')
-rw-r--r--src/tag.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/tag.c b/src/tag.c
index 56f84a85f..4c3d811eb 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -139,16 +139,19 @@ int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
return -1;
}
- if( *buffer != '\n' )
- return tag_error("No new line before message");
+ tag->message = NULL;
+ if (buffer < buffer_end) {
+ if( *buffer != '\n' )
+ return tag_error("No new line before message");
- text_len = buffer_end - ++buffer;
+ text_len = buffer_end - ++buffer;
- tag->message = git__malloc(text_len + 1);
- GITERR_CHECK_ALLOC(tag->message);
+ tag->message = git__malloc(text_len + 1);
+ GITERR_CHECK_ALLOC(tag->message);
- memcpy(tag->message, buffer, text_len);
- tag->message[text_len] = '\0';
+ memcpy(tag->message, buffer, text_len);
+ tag->message[text_len] = '\0';
+ }
return 0;
}