git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sparse-checkout: avoid staging deletions of all files

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 4, 2020, 17:18 UTC
Message-ID
<xmqqsgfapx5i.fsf@gitster.c.googlers.com>
In-Reply-To
<CABPp-BFmFd7gxN7cd04GFD9kCFEMbfXdv7dHCYRB4z21AUpZWQ@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 13 quoted lines
>> 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
	...
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 9 in “sparse-checkout: avoid staging deletions of all files”
  1. sparse-checkout: avoid staging deletions of all filesElijah Newren via GitGitGadget, Jun 4, 2020
  2. Derrick StoleeJun 4, 2020
  3. Elijah NewrenJun 4, 2020
  4. Derrick StoleeJun 4, 2020
  5. Junio C HamanoJun 4, 2020
  6. Junio C HamanoJun 4, 2020
  7. Junio C HamanoJun 4, 2020
  8. Junio C HamanoJun 4, 2020
  9. sparse-checkout: avoid staging deletions of all filesElijah Newren via GitGitGadget, Jun 5, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.