Re: [PATCH v2 05/12] diff: refactor output of incomplete line
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 10, 2025, 10:06 UTC
- Message-ID
- <aRG5KeoZg1Q1y8DE@pks.im>
- In-Reply-To
- <20251105213052.1499224-6-gitster@pobox.com>
On Wed, Nov 05, 2025 at 01:30:45PM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> Create a helper function that reacts to "\ No newline at the end of > file" in preparation for unifying the incomplete line handling in > the code path that handles xdiff output and the code path that > bypasses xdiff and produces complete rewrite patch. > > Signed-off-by: Junio C Hamano <gitster@pobox.com> > --- > diff.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/diff.c b/diff.c > index e73320dfb1..d388d318e4 100644 > --- a/diff.c > +++ b/diff.c > @@ -1379,6 +1379,10 @@ static void emit_diff_symbol_from_struct(struct diff_options *o, > emit_line(o, "", "", line, len); > break; > case DIFF_SYMBOL_CONTEXT_INCOMPLETE: > + set = diff_get_color_opt(o, DIFF_CONTEXT); > + reset = diff_get_color_opt(o, DIFF_RESET); > + emit_line(o, set, reset, line, len); > + break; > case DIFF_SYMBOL_CONTEXT_MARKER: > context = diff_get_color_opt(o, DIFF_CONTEXT); > reset = diff_get_color_opt(o, DIFF_RESET);
I found it a bit confusing that we use `set`/`reset` here instead of `context`/`reset` as before. It doesn't make any difference as these are local variables anyway, but it might make sense to explain why you chose to use different variables.
Honestly, this whole hunk is somewhat confusing in the first place. It doesn't seem to connect with the description in any way, as it's a no-op change and we don't even use the newly introduced function.
Patrick