Re: [PATCH 04/21] Refactor verification of "tagger" line to be more similar to verification of "type" and "tagger" lines
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 9, 2007, 18:01 UTC
- Message-ID
- <7vr6olf1m7.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <200706090214.11589.johan@herland.net>
Johan Herland <johan@herland.net> writes:
Show 22 quoted lines
> Also update selftests to reflect that verification of "tagger" now
> happens _before_ verification of type name, object sha1 and tag name.
>
> Signed-off-by: Johan Herland <johan@herland.net>
> ---
> mktag.c | 16 ++++++++--------
> t/t3800-mktag.sh | 3 +++
> tag.c | 6 +++---
> 3 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/mktag.c b/mktag.c
> index 0bc20c8..4dbefab 100644
> --- a/mktag.c
> +++ b/mktag.c
> @@ -62,12 +62,18 @@ static int verify_tag(char *data, unsigned long size)
>
> /* Verify tag-line */
> tag_line = strchr(type_line, '\n');
> - if (!tag_line)
> + if (!tag_line++)
> return error("char" PD_FMT ": could not find next \"\\n\"", type_line - data);
> - tag_line++;Code churn "while we are at it" makes reviewing the rest more cumbersome. A clean-up like this should be a separate patch.
Show 18 quoted lines
> diff --git a/tag.c b/tag.c
> index 8d31603..19c66cd 100644
> --- a/tag.c
> +++ b/tag.c
> @@ -73,10 +73,10 @@ static int parse_tag_buffer_internal(struct tag *item, const char *data, const u
> if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
> return error("char" PD_FMT ": no \"tag \" found", tag_line - data);
>
> + /* Verify the tagger line */
> tagger_line = strchr(tag_line, '\n');
> - if (!tagger_line)
> - return -1;
> - tagger_line++;
> + if (!tagger_line++)
> + return error("char" PD_FMT ": could not find next \"\\n\"", tag_line - data);
>
> /* Get the actual type */
> type_len = tag_line - type_line - strlen("type \n");Same comments on extra verbosity, as for [2/21].