Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Junio C Hamano
Jeff King p...@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 ==

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Jeff King
On Wed, Aug 27, 2014 at 10:30:22AM -0700, Junio C Hamano wrote: Jeff King p...@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

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Jeff King
On Wed, Aug 27, 2014 at 02:00:16PM -0400, Jeff King wrote: That may be something some callers want, but they should build it separately around this find_commit_header, so that callers that want a single line (like encoding or author) do not have to pay the price. I didn't bother building it

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Wed, Aug 27, 2014 at 10:30:22AM -0700, Junio C Hamano wrote: Jeff King p...@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

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Jeff King
On Wed, Aug 27, 2014 at 12:05:06PM -0700, Junio C Hamano wrote: 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

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Junio C Hamano
Jeff King p...@peff.net writes: I think they are a direct tradeoff. If you include only the first line, then callers who want multiple lines have to keep parsing. If you include multiple lines, then callers who care only about the first line will have to re-find the newline rather than just

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Jeff King
On Wed, Aug 27, 2014 at 12:26:56PM -0700, Junio C Hamano wrote: I don't mind returning -1 in out_len and have the callers check. That way will allow callers to easily diagnose this tree $T author $GIT_AUTHOR_IDENT committer $GIT_COMMITTER_IDENT encoding encoding

Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer

2014-08-27 Thread Junio C Hamano
Jeff King p...@peff.net writes: What I didn't want to do is deal with it in each callsite, like: OK. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html