From: Junio C Hamano <gitster@pobox.com>
To: "Krushnal Patel via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Krushnal Patel <krushnalpatel11@gmail.com>
Subject: Re: [PATCH] replace test -f with test_path_is_file
Date: Fri, 19 Mar 2021 11:04:28 -0700 [thread overview]
Message-ID: <xmqqr1kbm34j.fsf@gitster.g> (raw)
In-Reply-To: <pull.982.git.git.1616147527082.gitgitgadget@gmail.com> (Krushnal Patel via GitGitGadget's message of "Fri, 19 Mar 2021 09:52:06 +0000")
"Krushnal Patel via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: krush11 <krushnalpatel11@gmail.com>
>
> Although has the same functionality as test_path_is_file(), in
> the case where test_path_is_file() fails, we get much better debugging
> information.
>
> Replace with test_path_is_file so that future developers
> will have a better experience debugging these test cases.
While this change is not wrong per-se, in the context of this test
script, I think the original use of "test -f" is not quite right to
begin with. These are all "even after running 'git clean', these
paths should exist without getting removed by mistake", so the
intent of these "test -f" invocations are actually "test -e".
Similarly, the invocations of "test ! -f" we see (and there also is
at least one "! test -d") mean to say "these paths should be gone as
the result of running 'git clean'". If by some accident a directory
exists at the path that is checked with "test ! -f" due to a bug in
'git clean', these tests will not catch such a bug, because a directory
does not pass "test -f".
So most likely these negative tests this patch does not convert are
better off being spelled as "! test -e", too.
It would be more appropriate to use test_path_exists and
test_path_is_missing to replace these "must exist as a file" and
"must not exist as a file".
Thanks.
next prev parent reply other threads:[~2021-03-19 18:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 9:52 [PATCH] replace test -f with test_path_is_file Krushnal Patel via GitGitGadget
2021-03-19 18:04 ` Junio C Hamano [this message]
2021-03-19 19:24 ` [PATCH v2 0/2] " Krushnal Patel via GitGitGadget
2021-03-19 19:24 ` [PATCH v2 1/2] " krush11 via GitGitGadget
2021-03-19 19:24 ` [PATCH v2 2/2] replaced test -f and test ! -f krush11 via GitGitGadget
2021-03-19 20:34 ` 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=xmqqr1kbm34j.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=krushnalpatel11@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.