All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
	Erik Faye-Lund <kusmabite@gmail.com>
Subject: Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer
Date: Wed, 27 Aug 2014 10:30:22 -0700	[thread overview]
Message-ID: <xmqqioldet75.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140827075600.GA26384@peff.net> (Jeff King's message of "Wed, 27 Aug 2014 03:56:01 -0400")

Jeff King <peff@peff.net> writes:

> +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.

  reply	other threads:[~2014-08-27 17:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  7:55 [PATCH v2 0/6] clean up author parsing Jeff King
2014-08-27  7:56 ` [PATCH v2 1/6] commit: provide a function to find a header in a buffer Jeff King
2014-08-27 17:30   ` Junio C Hamano [this message]
2014-08-27 18:00     ` Jeff King
2014-08-27 18:16       ` Jeff King
2014-08-27 19:05       ` Junio C Hamano
2014-08-27 19:14         ` Jeff King
2014-08-27 19:26           ` Junio C Hamano
2014-08-27 19:38             ` Jeff King
2014-08-27 19:41               ` Junio C Hamano
2014-08-27  7:56 ` [PATCH v2 2/6] record_author_info: fix memory leak on malformed commit Jeff King
2014-08-27  7:56 ` [PATCH v2 3/6] record_author_info: use find_commit_header Jeff King
2014-08-27  7:57 ` [PATCH v2 4/6] use strbufs in date functions Jeff King
2014-08-27  7:57 ` [PATCH v2 5/6] determine_author_info: reuse parsing functions Jeff King
2014-08-27  7:57 ` [PATCH v2 6/6] determine_author_info: copy getenv output Jeff King
2014-08-27  9:06 ` [PATCH v2 0/6] clean up author parsing Christian Couder
2014-08-27 14:18   ` Jeff King
2014-08-27 17:36 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqioldet75.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.