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 12:05:06 -0700 [thread overview]
Message-ID: <xmqqwq9tda8t.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140827180016.GA6269@peff.net> (Jeff King's message of "Wed, 27 Aug 2014 14:00:16 -0400")
Jeff King <peff@peff•net> writes:
> On Wed, Aug 27, 2014 at 10:30:22AM -0700, Junio C Hamano wrote:
>
>> Jeff King <peff@peff•net> writes:
>>
>> > +const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
>> [...]
>>
>> 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.
>
> If you mean parsing past continuation lines, then no, we do not need to
> worry. We go line by line and look for the key at the beginning of a
> line, so we would skip past any continuation lines.
>
> If you mean including continuation lines in the output, I don't think
> that's a good idea here. It would mean the function would have to copy
> the value out (to get rid of the continuation whitespace) rather than
> point directly into the msg buffer.
I meant the counting of out_len. You do not copy the contents for
the caller for a single line case either, so I wouldn't expect it.
You locate where the stuff begins to make it easier for the caller
to read or copy, and the caller may choose to stop reading from the
location up to out_len bytes, or it may choose to ignore out_len and
stop at the first newline. For the latter kind of caller, it does
not matter if out_len does not point at the end of the "field"
(i.e. for a continued-line case), but for the former, wouldn't it be
more useful if out_len told where the end of the "field" is?
next prev parent reply other threads:[~2014-08-27 19:05 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
2014-08-27 18:00 ` Jeff King
2014-08-27 18:16 ` Jeff King
2014-08-27 19:05 ` Junio C Hamano [this message]
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=xmqqwq9tda8t.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=kusmabite@gmail$(echo .)com \
--cc=peff@peff$(echo .)net \
--cc=sunshine@sunshineco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox