X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=tag.c;h=28641cf85a0d32357269129f0e8b92bb9e21f399;hb=HEAD;hp=ceb86557c5eedb03cbdc81929b7d109b44d440d5;hpb=28de5b6b400fcdbd2d0665bc0cec7d7e4b813b43;p=git.git diff --git a/tag.c b/tag.c index ceb86557c..28641cf85 100644 --- a/tag.c +++ b/tag.c @@ -28,12 +28,29 @@ struct tag *lookup_tag(const unsigned char *sha1) return create_object(sha1, OBJ_TAG, alloc_tag_node()); if (!obj->type) obj->type = OBJ_TAG; - if (obj->type != OBJ_TAG) { - error("Object %s is a %s, not a tag", - sha1_to_hex(sha1), typename(obj->type)); - return NULL; - } - return (struct tag *) obj; + if (obj->type != OBJ_TAG) { + error("Object %s is a %s, not a tag", + sha1_to_hex(sha1), typename(obj->type)); + return NULL; + } + return (struct tag *) obj; +} + +static unsigned long parse_tag_date(const char *buf, const char *tail) +{ + const char *dateptr; + + while (buf < tail && *buf++ != '>') + /* nada */; + if (buf >= tail) + return 0; + dateptr = buf; + while (buf < tail && *buf++ != '\n') + /* nada */; + if (buf >= tail) + return 0; + /* dateptr < buf && buf[-1] == '\n', so strtoul will stop at buf-1 */ + return strtoul(dateptr, NULL, 10); } int parse_tag_buffer(struct tag *item, void *data, unsigned long size) @@ -86,6 +103,11 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size) item->tag = xmemdupz(bufptr, nl - bufptr); bufptr = nl + 1; + if (!prefixcmp(bufptr, "tagger ")) + item->date = parse_tag_date(bufptr, tail); + else + item->date = 0; + return 0; }