From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: Derrick Stolee <stolee@gmail.com>,
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Shaun Case <warmsocks@gmail.com>
Subject: Re: [PATCH] sparse-checkout: avoid staging deletions of all files
Date: Thu, 04 Jun 2020 10:18:33 -0700 [thread overview]
Message-ID: <xmqqsgfapx5i.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <CABPp-BFmFd7gxN7cd04GFD9kCFEMbfXdv7dHCYRB4z21AUpZWQ@mail.gmail.com> (Elijah Newren's message of "Thu, 4 Jun 2020 08:05:06 -0700")
Elijah Newren <newren@gmail.com> writes:
>> My only comment on the test case is to see if you could use
>> the "check_files" macro instead of "ls". See 761e3d26
>> (sparse-checkout: improve OS ls compatibility, 2019-12-20)
>> for details.
>
> I attempted to do so initially, but that function fails badly when
> there are no files (other than the "hidden" files '.git', '.', and
> '..') in the directory. The reason for this comes from the "printf
> '%s\n' *" -- the glob won't match anything and so it prints a literal
> asterisk, which is not helpful.
>
> I thought about writing an asterisk out to the expected file for
> comparison, but that just made the testcase look confusing.
Maybe. It is clear that the implementation ignores the possibility
that it can be asked to check for an empty directory.
list_files() {
# Do not replace this with 'ls "$1"', as "ls" with BSD-lineage
# enables "-A" by default for root and ends up including ".git" and
# such in its output. (Note, though, that running the test suite as
# root is generally not recommended.)
(cd "$1" && printf '%s\n' *)
}
The comment does not even talk about the possibility that glob '*'
may fail to glob anything.
Instead of letting the macro spend an extra subprocess, using ls
ourselves but in a bit more defensive way would help? I.e.
...
# nothing checked out, expect "No such file or directory"
! ls clone_no_checkout/* >actual &&
test_must_be_empty actual
test_path_is_missing clone_no_checkout/.git/index
...
next prev parent reply other threads:[~2020-06-04 17:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 8:17 [PATCH] sparse-checkout: avoid staging deletions of all files Elijah Newren via GitGitGadget
2020-06-04 14:48 ` Derrick Stolee
2020-06-04 15:05 ` Elijah Newren
2020-06-04 15:23 ` Derrick Stolee
2020-06-04 17:08 ` Junio C Hamano
2020-06-04 17:18 ` Junio C Hamano [this message]
2020-06-04 17:21 ` Junio C Hamano
2020-06-04 16:57 ` Junio C Hamano
2020-06-05 2:41 ` [PATCH v2] " Elijah Newren via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqsgfapx5i.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=newren@gmail.com \
--cc=stolee@gmail.com \
--cc=warmsocks@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).