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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/4/2020 11:05 AM, Elijah Newren wrote:
> On Thu, Jun 4, 2020 at 7:48 AM Derrick Stolee <stolee@xxxxxxxxx> 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





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux