From: Eric Sunshine Date: Sun, 14 Apr 2019 23:21:35 GMT Subject: Re: [RFC PATCH 2/4] range-diff: don't remove funcname from inner diff Message-ID: In-Reply-To: <20190414210933.20875-3-t.gummerer@gmail.com> On Sun, Apr 14, 2019 at 5:09 PM Thomas Gummerer wrote: > [...] > However it can still be useful to have the function name that 'git > diff' extracts as additional context for the change. > [...] > Signed-off-by: Thomas Gummerer > --- > diff --git a/range-diff.c b/range-diff.c > @@ -102,9 +102,12 @@ static int read_patches(const char *range, struct string_list *list) > + } else if (starts_with(line.buf, "@@ ")) { > + char *skip_lineno = strstr(line.buf + 3, "@@"); > + strbuf_remove(&line, 0, skip_lineno - line.buf); It makes me a bit uncomfortable that this is not checking for NULL return from strstr() before doing pointer arithmetic (even though the input is presumably machine-generated). if (!skip_lineno) BUG(...); might be appropriate. > + strbuf_addch(&buf, ' '); > + strbuf_addbuf(&buf, &line);