Skip to content

Make tag date readable

username-removed-94717 requested to merge YueLinHo/tortoisegit:tag_time into master

The format of tag header:

object [COMMIT_SHA1_VALUE]
type commit
tag [TAG_NAME]
tagger [USER_NAME] <[USER_MAIL]> [TAG_TIME]

git uses similar way to parse tag date:

static timestamp_t 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 parsing will stop at buf-1 */
     return parse_timestamp(dateptr, NULL, 10);
}

(Also see here)

And cf. this commit, the log message:

Just like with committer dates, we parse the tagger date into the
struct tag so its available for further downstream processing.
However since the tagger header was not introduced until Git 0.99.1
we must consider it optional. For tags missing this header we use
the default date of 0.

Merge request reports