Johan Herland [off-list ref] writes:
Teach git-fsck to do the same kind of verification on tag objects that is
already done by git-mktag.
The tagger field was introduced mid July 2005; any repository
with a tag object older than that would now get non-zero exit
from fsck.
This won't practically be problem in newer repositories, but it
is somewhat annoying. Perhaps do this only under the new -v
option to git-fsck, say "warning" not "error", and not exit with
non-zero because of this?
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 <redacted>
---
On Wednesday 06 June 2007, Junio C Hamano wrote:
The tagger field was introduced mid July 2005; any repository
with a tag object older than that would now get non-zero exit
from fsck.
This won't practically be problem in newer repositories, but it
is somewhat annoying. Perhaps do this only under the new -v
option to git-fsck, say "warning" not "error", and not exit with
non-zero because of this?
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