All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Matheus Tavares <matheus.bernardino@usp.br>
Cc: git@vger.kernel.org, newren@gmail.com, gitster@pobox.com,
	stolee@gmail.com, vdye@github.com, derrickstolee@github.com,
	Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Subject: Re: [PATCH v2] add, rm, mv: fix bug that prevents the update of non-sparse dirs
Date: Wed, 27 Oct 2021 17:36:15 +0000	[thread overview]
Message-ID: <YXmOD9fl+K0RSOpt@google.com> (raw)
In-Reply-To: <5e99c039db0b9644fb21f2ea72a464c67a74ff64.1635191000.git.matheus.bernardino@usp.br>

On Mon, Oct 25, 2021, Matheus Tavares wrote:
> - Changed the tests to use trailing slash to make sure they cover the corner
>   case described above.

...

> diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh
> index 5b904988d4..54f3db4304 100755
> --- a/t/t3705-add-sparse-checkout.sh
> +++ b/t/t3705-add-sparse-checkout.sh
> @@ -214,4 +214,22 @@ test_expect_success 'add allows sparse entries with --sparse' '
>  	test_must_be_empty stderr
>  '
>  
> +test_expect_success 'can add files from non-sparse dir' '
> +	git sparse-checkout set w !/x y/ &&

Aha!  I re-discovered out the original problematic pattern that led me to omitting
the trailing slash.

Sparse checkout doesn't play nice with "/", e.g. "git sparse-checkout set /"
results in an empty working directory.  Using "/*/" omits top-level files, which
is expected, thus the only pattern that works for "include everything relative to
the top-level directory" is "/*".  And to workaround the bug being fixed here, it
requires adding both "/*" and "/*/" to sparse-checkout.

The docs clearly state that "/*" is the full pattern set, but on the other hand
I don't see anything that states that "/" isn't supported.  Part of the confusion
is that the asterisk is not needed for sub-directories, and a trailing slash for
sub-directories even results in different matching behavior per gitignore docs.
The omission of a trailing slash is also reinforced by the git-sparse-checkout
docs' examples.

If "/" can't be handled for some reason, it would helpful to explictly call that
out in the docs, e.g. git-sparse-checkout and/or the gitignore pattern docs.

Thanks!

> +	mkdir -p w x/y &&
> +	touch w/f x/y/f &&
> +	git add w/f x/y/f 2>stderr &&
> +	test_must_be_empty stderr
> +'
> +
> +test_expect_success 'refuse to add non-skip-worktree file from sparse dir' '
> +	git sparse-checkout set !/x y/ !x/y/z &&
> +	mkdir -p x/y/z &&
> +	touch x/y/z/f &&
> +	test_must_fail git add x/y/z/f 2>stderr &&
> +	echo x/y/z/f | cat sparse_error_header - sparse_hint >expect &&
> +	test_cmp expect stderr
> +

  parent reply	other threads:[~2021-10-27 17:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 21:07 [PATCH v2] add, rm, mv: fix bug that prevents the update of non-sparse dirs Matheus Tavares
2021-10-26 12:53 ` Derrick Stolee
2021-10-26 22:43   ` Matheus Tavares
2021-10-27 11:35     ` Derrick Stolee
2021-10-26 16:22 ` René Scharfe
2021-10-26 19:04   ` Derrick Stolee
2021-10-27  0:00     ` Matheus Tavares
2021-10-27 22:13     ` Chris Torek
2021-10-27 17:36 ` Sean Christopherson [this message]
2021-10-28 14:21 ` [PATCH v3] " Matheus Tavares
2021-10-28 15:06   ` Derrick Stolee
2021-10-28 15:58     ` 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=YXmOD9fl+K0RSOpt@google.com \
    --to=seanjc@google.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=matheus.bernardino@usp.br \
    --cc=newren@gmail.com \
    --cc=stolee@gmail.com \
    --cc=vdye@github.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.