Re: [RFC PATCH 2/4] range-diff: don't remove funcname from inner diff
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Apr 15, 2019, 12:54 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1904151454010.44@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAPig+cSmh1rCTPj0Y=G4OA3TmoGqVBnj95S+KogOgiDtW_0DiQ@mail.gmail.com>
Hi Eric,
On Sun, 14 Apr 2019, Eric Sunshine wrote:
Show 19 quoted lines
> On Sun, Apr 14, 2019 at 5:09 PM Thomas Gummerer <t.gummerer@gmail.com> 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 <t.gummerer@gmail.com>
> > ---
> > 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(...);Good point, but maybe we should not go so far as to declare this a bug, and fall back to removing everything bug the initial two `at` characters instead?
Thanks, Dscho
Show 6 quoted lines
> > might be appropriate. > > > + strbuf_addch(&buf, ' '); > > + strbuf_addbuf(&buf, &line); >