From: Lidong Yan <yldhome2d2@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, hi@arnes.space, michal@isc.org, peff@peff.net
Subject: Re: [PATCH v3] diff: ensure consistent diff behavior with ignore options
Date: Thu, 7 Aug 2025 09:23:45 +0800 [thread overview]
Message-ID: <5E4D0147-A4DC-4906-9627-A92CE34A4754@gmail.com> (raw)
In-Reply-To: <xmqqikj0uze2.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
>
> The code looks much easier to reason about than the previous rounds.
>
> A few comments about the design.
>
> - Are there other possible values that might fit in this "optimize"
> member, and what kind of behaviour would they trigger, that we
> can envision? I do not think of any and that is why the "enum
> diff_optimize" member in the diff_options structure smells more
> like a "bool dry_run".
I was thinking about DIFF_OPT_BUFFER , but "bool dry_run" would be good
enough for now.
>
> By the way, giving a member "diff_" prefix when the enclosing
> struct is clearly about "diff" by having a name "diff_options" is
> often a waste of readers' time.
Good advice, field name should avoid overlapping with struct name.
>
> - It is unclear why the dry-run need to imply 0-line context.
I was thinking about matching ignored regex in `quick_consume()`, in which
case we only need to match regex for changes rather than context, so I set
ctxlen to zero. But anyway more `if` reduce both readability and maintainability,
so I won’t set ctxlen in the next version.
>
> - diff_flush_patch_quietly() would be a better name for
> diff_flush_patch_quiet().
Understand, I suppose the idea behind this is to stick to proper grammar as
much as possible when choosing names.
>
> On to the details.
>
>> diff --git a/diff.c b/diff.c
>> index dca87e164f..5254ef9373 100644
>> --- a/diff.c
>> +++ b/diff.c
>> @@ -2444,6 +2444,15 @@ static int fn_out_consume(void *priv, char *line, unsigned long len)
>> return 0;
>> }
>>
>> +static int quick_consume(void *priv, char *line, unsigned long len)
>> +{
>> + struct emit_callback *ecbdata = priv;
>> + struct diff_options *o = ecbdata->opt;
>> +
>> + o->found_changes = 1;
>> + return 1;
>> +}
>
> OK, as a non-zero return value from consume callbacks is supposed
> to signal an error and causes xdiff_outf() an early return, this
> serves as a short-cut. One downside is that we cannot truly notice
> and signal an error to our callers, as we will see in a later hunk.
I want to think about how to solve this problem later, but I believe I shouldn’t
address it in this patch.
Thanks,
Lidong
next prev parent reply other threads:[~2025-08-07 1:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 5:47 git-diff: --ignore-matching-lines has no effect on the output when --name-only is used hi
2025-07-23 8:00 ` Lidong Yan
2025-07-23 17:09 ` Junio C Hamano
2025-07-24 1:56 ` Lidong Yan
2025-07-24 2:16 ` Eric Sunshine
2025-07-24 3:38 ` Lidong Yan
2025-07-25 6:00 ` hi
2025-07-25 6:06 ` hi
2025-07-25 6:46 ` Lidong Yan
2025-07-25 8:08 ` hi
2025-07-25 11:11 ` Jeff King
2025-07-25 15:20 ` Junio C Hamano
2025-07-29 8:18 ` [PATCH] diff: ensure consistent diff behavior with -I<regex> across output formats Lidong Yan
2025-07-30 0:28 ` Junio C Hamano
2025-08-02 10:22 ` Jeff King
2025-08-03 8:42 ` Lidong Yan
2025-08-03 15:43 ` Junio C Hamano
2025-08-04 4:39 ` Junio C Hamano
2025-08-04 12:42 ` Jeff King
2025-08-03 14:51 ` [PATCH v2] " Lidong Yan
2025-08-04 0:39 ` Junio C Hamano
2025-08-04 1:56 ` Lidong Yan
2025-08-04 4:36 ` Junio C Hamano
2025-08-05 9:23 ` Lidong Yan
2025-08-05 16:11 ` Junio C Hamano
2025-08-06 12:33 ` [PATCH v3] diff: ensure consistent diff behavior with ignore options Lidong Yan
2025-08-06 17:35 ` Junio C Hamano
2025-08-07 1:23 ` Lidong Yan [this message]
2025-08-06 20:56 ` Junio C Hamano
2025-08-07 1:39 ` Lidong Yan
2025-08-07 2:06 ` [PATCH v4] " Lidong Yan
2025-08-07 21:27 ` Junio C Hamano
2025-08-08 1:46 ` Lidong Yan
2025-08-08 3:30 ` [PATCH v5] " Lidong Yan
2025-10-16 14:55 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5E4D0147-A4DC-4906-9627-A92CE34A4754@gmail.com \
--to=yldhome2d2@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hi@arnes.space \
--cc=michal@isc.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).