From: Junio C Hamano Date: Wed, 27 Aug 2014 17:30:22 GMT Subject: Re: [PATCH v2 1/6] commit: provide a function to find a header in a buffer Message-ID: In-Reply-To: <20140827075600.GA26384@peff.net> Jeff King 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.