Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 27, 2014, 17:30 UTC
- Message-ID
- <xmqqioldet75.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20140827075600.GA26384@peff.net>
Jeff King <peff@peff.net> writes:
Show 16 quoted lines
> +const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
> +{
> + int key_len = strlen(key);
> + const char *line = msg;
> +
> + while (line) {
> + const char *eol = strchrnul(line, '\n');
> +
> + if (line == eol)
> + return NULL;
> +
> + if (eol - line > key_len &&
> + !strncmp(line, key, key_len) &&
> + line[key_len] == ' ') {
> + *out_len = eol - line - key_len - 1;
> + return line + key_len + 1;Hmph. Does this have to worry about continuation lines in the header part e.g. mergetag? If the original in pretty.c was only about the encoding, it may not have mattered, but now because it is made public, it may matter more.