From: Johan Herland Date: Sat, 09 Jun 2007 00:17:17 GMT Subject: [PATCH 11/21] Rewrite error messages; fix up line lengths Message-ID: <200706090217.17795.johan@herland.net> In-Reply-To: <200706090210.36270.johan@herland.net> Also update selftests to reflect new error messages. Signed-off-by: Johan Herland --- t/t3800-mktag.sh | 22 +++++++++++----------- tag.c | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0e87d2a..3bce5e0 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -49,7 +49,7 @@ tag mytag EOF cat >expect.pat <expect.pat <expect.pat <tag.sig printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig cat >expect.pat <expect.pat <expect.pat <expect.pat <expect.pat <expect.pat <expect.pat <expect.pat <= sizeof(type)) - return error("char" PD_FMT ": type too long", type_line + 5 - data); + return error("Tag object (@ char " PD_FMT "): " + "Type too long", type_line + 5 - data); memcpy(type, type_line + 5, type_len); type[type_len] = '\0'; @@ -115,16 +124,20 @@ int parse_and_verify_tag_buffer(struct tag *item, /* Verify that the object matches */ if (verify_object(sha1, type)) - return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1)); + return error("Tag object (@ char 7): " + "Could not verify tagged object %s", + sha1_to_hex(sha1)); - /* Verify the tag-name: we don't allow control characters or spaces in it */ + /* Verify tag name: disallow control characters or spaces */ for (i = 4;;) { unsigned char c = tag_line[i++]; if (c == '\n') break; if (c > ' ') continue; - return error("char" PD_FMT ": could not verify tag name", tag_line + i - data); + return error("Tag object (@ char " PD_FMT "): " + "Could not verify tag name", + tag_line + i - data); } /* Verify the tagger line */ @@ -148,7 +161,8 @@ int parse_and_verify_tag_buffer(struct tag *item, } else if (!strcmp(type, tag_type)) { item->tagged = &lookup_tag(sha1)->object; } else { - error("Unknown type %s", type); + error("Tag object (@ char " PD_FMT "): " + "Unknown type '%s'", type_line + 5 - data, type); item->tagged = NULL; } -- 1.5.2