[PATCH 17/21] Update comments on tag objects in mktag.c
From: Johan Herland <hidden>
Date: 2016-06-15 22:43:14
Subsystem:
the rest · Maintainer:
Linus Torvalds
Also update minimum tag object length to the new minimum length after refactoring. Signed-off-by: Johan Herland <redacted> --- mktag.c | 30 ++++++++++++++++++++++-------- tag.c | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/mktag.c b/mktag.c
index 31eadd8..af0cfa6 100644
--- a/mktag.c
+++ b/mktag.c@@ -2,16 +2,30 @@ #include "tag.h" /* - * A signature file has a very simple fixed format: four lines - * of "object <sha1>" + "type <typename>" + "tag <tagname>" + + * Tag object data has the following format: two mandatory lines of + * "object <sha1>" + "type <typename>", plus two optional lines of + * "tag <tagname>" + "keywords <keywords>", plus a mandatory line of * "tagger <committer>", followed by a blank line, a free-form tag - * message and a signature block that git itself doesn't care about, - * but that can be verified with gpg or similar. + * message and an optional signature block that git itself doesn't + * care about, but that can be verified with gpg or similar. * - * The first three lines are guaranteed to be at least 63 bytes: - * "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the - * shortest possible type-line, and "tag .\n" at 6 bytes is the - * shortest single-character-tag line. + * <sha1> represents the object pointed to by this tag, <typename> is + * the type of the object pointed to ("tag", "blob", "tree" or "commit"), + * <tagname> is the name of this tag object (and must correspond to the + * name of the corresponding ref (if any) in '.git/refs/'). <keywords> is + * a comma-separated list of keywords associated with this tag object, and + * <committer> holds the "name <email>" of the tag creator and timestamp + * of when the tag object was created (analogous to "committer" in commit + * objects). + * + * The first two lines are guaranteed to be at least 57 bytes: + * "object <sha1>\n" is 48 bytes, and "type tag\n" at 9 bytes is + * the shortest possible "type" line. The tagger line is at least + * "tagger \n" (8 bytes). Therefore a tag object _must_ have >= 65 bytes. + * + * If "tag <tagname>" is omitted, <tagname> defaults to the empty string. + * If "keywords <keywords>" is omitted, <keywords> defaults to "tag" if + * a <tagname> was given, "note" otherwise. */ int main(int argc, char **argv)
diff --git a/tag.c b/tag.c
index 1caec19..af4356e 100644
--- a/tag.c
+++ b/tag.c@@ -79,7 +79,7 @@ int parse_and_verify_tag_buffer(struct tag *item, item->object.parsed = 1; } - if (size < 64) + if (size < 65) return error("Tag object failed preliminary size check"); /* Verify mandatory object line */
--
1.5.2