Re: [PATCH 1/3] diff.c: add --output-indicator-{new, old, context}
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 21, 2018, 16:13 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1808211813020.73@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAGZ79kY8oadQ2nKWr7znMa8QJgLcidb0FefPDBaba+q2J=nfPg@mail.gmail.com>
Hi Stefan,
On Mon, 20 Aug 2018, Stefan Beller wrote:
Show 44 quoted lines
> On Mon, Aug 20, 2018 at 12:31 PM Johannes Schindelin > <Johannes.Schindelin@gmx.de> wrote: > > > > On Fri, 17 Aug 2018, Stefan Beller wrote: > > > > > This will prove useful in range-diff in a later patch as we will be able > > > to differentiate between adding a new file (that line is starting with > > > +++ and then the file name) and regular new lines. > > > > > > It could also be useful for experimentation in new patch formats, i.e. > > > we could teach git to emit moved lines with lines other than +/-. > > > > Thanks. > > > > > diff --git a/diff.c b/diff.c > > > index c5c7739ce34..03486c35b75 100644 > > > --- a/diff.c > > > +++ b/diff.c > > > @@ -1281,7 +1281,9 @@ static void emit_diff_symbol_from_struct(struct diff_options *o, > > > else if (c == '-') > > > set = diff_get_color_opt(o, DIFF_FILE_OLD); > > > } > > > - emit_line_ws_markup(o, set_sign, set, reset, ' ', line, len, > > ^ > > Here we already pass `o`... so... > > > > > + emit_line_ws_markup(o, set_sign, set, reset, > > > + o->output_indicators[OUTPUT_INDICATOR_CONTEXT], > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ... here, we could simply pass `OUTPUT_INDICATOR_CONTEXT` and let the > > callee look it up in`o->output_indicators[]`... > > > > I read all three patches and did not see a reason why we could not > > simplify the code that way. > > > > Other than that: great! > > Thanks! > > I considered it, but was put off by the (small) effort of yet another > diff refactoring. > > I'll include it in a resend if a resend is needed, otherwise > I would suggest to make it a patch on top?
Sounds good! Dscho