Re: [PATCH 1/3] diff.c: add --output-indicator-{new, old, context}
From: Stefan Beller <hidden>
Date: 2018-08-20 19:40:14
On Mon, Aug 20, 2018 at 12:31 PM Johannes Schindelin [off-list ref] wrote:
Hi Stefan, On Fri, 17 Aug 2018, Stefan Beller wrote:quoted
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.quoted
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...quoted
+ 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? Thanks, Stefan