All of lore.kernel.org
 help / color / mirror / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: Elijah Newren <newren@gmail.com>
Cc: 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, 4 Jun 2020 11:23:26 -0400	[thread overview]
Message-ID: <6e5970f6-9b9b-19ba-1035-f4f53d9ac030@gmail.com> (raw)
In-Reply-To: <CABPp-BFmFd7gxN7cd04GFD9kCFEMbfXdv7dHCYRB4z21AUpZWQ@mail.gmail.com>

On 6/4/2020 11:05 AM, Elijah Newren wrote:
> On Thu, Jun 4, 2020 at 7:48 AM Derrick Stolee <stolee@gmail.com> wrote:
>>
>> On 6/4/2020 4:17 AM, Elijah Newren via GitGitGadget wrote:
>>> +test_expect_success 'interaction with clone --no-checkout (unborn index)' '
>>> +     git clone --no-checkout "file://$(pwd)/repo" clone_no_checkout &&
>>> +     git -C clone_no_checkout sparse-checkout init --cone &&
>>> +     git -C clone_no_checkout sparse-checkout set folder1 &&
>>> +     git -C clone_no_checkout sparse-checkout list >actual &&
>>> +     cat >expect <<-\EOF &&
>>> +     folder1
>>> +     EOF
>>> +     test_cmp expect actual &&
>>> +     ls clone_no_checkout >actual &&
>>> +     test_must_be_empty actual &&
>>
>> 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.  It was a
> lot cleaner to just use ls with no glob coupled with
> test_must_be_empty.
> 
>>> +     test_path_is_missing clone_no_checkout/.git/index &&
>>> +
>>> +     # No branch is checked out until we manually switch to one
>>> +     git -C clone_no_checkout switch master &&
>>> +     test_path_is_file clone_no_checkout/.git/index &&
>>> +     check_files clone_no_checkout a folder1
> 
> However, when I did have files in the directory, then I used your
> check_files function as seen here.  :-)
> 
> 
> Does that make sense, or is there a better alternative?

Unfortunately, we'll still have the platform issue, since there
_is_ a .git directory. To repeat the commit message for 761e3d26:

    On FreeBSD, when executed by root ls enables the '-A' option:
    
      -A  Include directory entries whose names begin with a dot (`.')
          except for . and ...  Automatically set for the super-user unless
          -I is specified.
    
    As a result the .git directory appeared in the output when run as root.
    Simulate no-dotfile ls behaviour using a shell glob.

So maybe be purposeful and include the -a option and expect only the
.git dir (along with . and ..)?

Something like:

	cat >expect <<-\EOF &&
	.
	..
	.git
	EOF
	ls -a clone_no_checkout >actual &&
	test_cmp expect actual &&

Thanks,
-Stolee



  reply	other threads:[~2020-06-04 15:23 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 [this message]
2020-06-04 17:08       ` Junio C Hamano
2020-06-04 17:18     ` Junio C Hamano
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e5970f6-9b9b-19ba-1035-f4f53d9ac030@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@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.
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.