From: Johannes Altmanninger <aclopte@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re* [PATCH] diff: suppress --name-only paths where all hunks are ignored
Date: Sun, 20 Dec 2020 23:34:35 +0100 [thread overview]
Message-ID: <20201220223435.tmo5ty5tzwu7et4d@gmail.com> (raw)
In-Reply-To: <xmqq4kkl1atq.fsf@gitster.c.googlers.com>
On Wed, Dec 16, 2020 at 05:27:13PM -0800, Junio C Hamano wrote:
> Johannes Altmanninger <aclopte@gmail.com> writes:
> > The diff_from_contents bit means that we have to look at content
> > changes to know if a path has changed - modulo ignored hunks.
>
> But your sentence without " - modulo ignored hunks" says that very
> clearly. So perhaps these three words can just go away?
My bad, this should rather be
The diff_from_contents bit means that we have to look at content
changes (modulo ignored hunks) to know if a path has changed.
probably dropping the three words makes it even less confusing.
> It's not like we were buggy when diff_from_contents bit is in effect
> for all output formats, is it?
Right, it's useless to set the bit here.
> > + opt->color_moved = 0;
>
> Why is color_moved so special? If we added some other new option,
> how would we make sure that the person who is adding that new option
> would remember to reset it here? And how does that person decide if
> his or her new option needs resetting or not in the first place?
I copied color_moved=0 from the DIFF_FORMAT_NO_OUTPUT section of
diff_flush(). It happens to work correctly in both places because no diff
contents are printed, but yeah it's not robust to future changes.
> Also I am not sure if "caching" the file handle to /dev/null is
> good idea or not. When will it be closed? Would repeated
> invocation of the diff machinery work well with it (think: "git log
> -w --name-only")
I believe that repeated invocations work fine, because the file is never
closed (which may be a problem?). The file could be made nilable if we still
need something like that.
> This somehow feels wrong. For one thing, RAW is about showing
> object names of preimage and postimage, which means it shows the
> preimage and postimage are either identical or different, and
> options like -w, -I, etc. that inspect and hide some textual
> differences should not affect its outcome at all.
Yeah, I realized late that -w --raw will have sort of unintuitive semantics.
This combination is probably rare but I guess users could set an alias for
diff -w.
> I am tempted to declare that just like "raw", "name-only" and
> "name-status" formats work with byte-for-byte equality
OK, I think it's better to keep the current (consistent) behavior. I don't
think it's worth to special-case "--name-only".
It's easy to read the names from a "diff -I" output anyway. This filter is
broken in various ways, but works well enough in practise:
diff -I | perl -ne 'print "$1\n" if /\+{3} b\/(.*)/'
> and "-w" and friends are ignored just like in "diff --name-status --patch"
> the "--patch" option is ignored.
For interactive use, it would be more helpful to reject useless options
instead of ignoring them. Though ignoring is probably desirable to allow
liberal use of these options, I'm not sure.
> --- >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ---
>
> Subject: [PATCH] diff: correct interaction between --exit-code and -I<pattern>
Looks good.
> +test_expect_success '-w and --exit-code interact sensibly' '
Maybe 'exit with 0 when all changes are ignored by -w' though either version
is fine because I think the intention of the test is already obvious.
next prev parent reply other threads:[~2020-12-21 5:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-14 19:00 Unexpected behavior on diff -I<regex> --name-only Johannes Altmanninger
2020-12-14 19:49 ` Junio C Hamano
2020-12-16 23:18 ` Johannes Altmanninger
2020-12-16 23:18 ` [PATCH] diff: suppress --name-only paths where all hunks are ignored Johannes Altmanninger
2020-12-17 1:27 ` Re* " Junio C Hamano
2020-12-20 22:34 ` Johannes Altmanninger [this message]
2020-12-21 19:29 ` Junio C Hamano
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=20201220223435.tmo5ty5tzwu7et4d@gmail.com \
--to=aclopte@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).