[PATCH 3/6] git-fsck: Do thorough verification of tag objects.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johan Herland
Date: Wednesday, June 6, 2007 - 1:06 am

Teach git-fsck to do the same kind of verification on tag objects that is
already done by git-mktag.

Signed-off-by: Johan Herland <johan@herland.net>
---

On Wednesday 06 June 2007, Junio C Hamano wrote:

Like this?

Or would you rather switch around the "verbose" and the
"parse_and_verify_tag_buffer()" (i.e. not even attempt the thorough
verification unless in verbose mode)?


Have fun!

...Johan

 builtin-fsck.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index bacae5d..fb9a8bb 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -359,11 +359,24 @@ static int fsck_commit(struct commit *commit)
 static int fsck_tag(struct tag *tag)
 {
 	struct object *tagged = tag->tagged;
+	enum object_type type;
+	unsigned long size;
+	char *data = (char *) read_sha1_file(tag->object.sha1, &type, &size);
 
 	if (verbose)
 		fprintf(stderr, "Checking tag %s\n",
 			sha1_to_hex(tag->object.sha1));
 
+	if (!data)
+		return objerror(&tag->object, "could not read tag");
+	if (type != OBJ_TAG) {
+		free(data);
+		return objerror(&tag->object, "not a tag (internal error)");
+	}
+	if (parse_and_verify_tag_buffer(0, data, size, 1) && verbose)
+		objwarning(&tag->object, "failed thorough tag object verification");
+	free(data);
+
 	if (!tagged) {
 		return objerror(&tag->object, "could not load tagged object");
 	}
-- 
1.5.2



-- 
Johan Herland, <johan@herland.net>
www.herland.net
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/6] Refactor the tag object, Johan Herland, (Sun Jun 3, 5:51 pm)
Re: [PATCH 3/6] git-fsck: Do thorough verification of tag ..., Matthias Lederhofer, (Sun Jun 3, 10:56 pm)
Re: [PATCH 0/6] Refactor the tag object, Junio C Hamano, (Mon Jun 4, 1:32 pm)
[PATCH 3/6] git-fsck: Do thorough verification of tag objects., Johan Herland, (Wed Jun 6, 1:06 am)
[PATCH 0/7] Introduce soft references (softrefs), Johan Herland, (Sat Jun 9, 11:19 am)
[PATCH 2/7] Softrefs: Add implementation of softrefs API, Johan Herland, (Sat Jun 9, 11:22 am)
Comment on weak refs, Junio C Hamano, (Sat Jun 9, 4:55 pm)
Re: Comment on weak refs, Johan Herland, (Sat Jun 9, 6:25 pm)
Re: Comment on weak refs, Johannes Schindelin, (Sat Jun 9, 11:33 pm)
Re: [PATCH 1/7] Softrefs: Add softrefs header file with AP ..., Johannes Schindelin, (Sat Jun 9, 11:58 pm)
Re: [PATCH 1/7] Softrefs: Add softrefs header file with AP ..., Johannes Schindelin, (Sun Jun 10, 12:54 am)
Re: [PATCH] Change softrefs file format from text (82 byte ..., Johannes Schindelin, (Sun Jun 10, 1:02 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 2:03 am)
Re: [PATCH] Change softrefs file format from text (82 byte ..., Johannes Schindelin, (Sun Jun 10, 2:46 am)
Re: Comment on weak refs, Johan Herland, (Sun Jun 10, 6:41 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 7:09 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 7:25 am)