Re: [PATCH v3 01/14] t3705: test that 'sparse_entry' is unstaged
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 22, 2021, 22:52 UTC
- Message-ID
- <xmqq7df85ilg.fsf@gitster.g>
- In-Reply-To
- <ea940f10a7cd26c6be3693b5a800afb7d6f752f2.1632159937.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 37 quoted lines
> From: Derrick Stolee <dstolee@microsoft.com>
>
> The tests in t3705-add-sparse-checkout.sh check to see how 'git add'
> behaves with paths outside the sparse-checkout definition. These
> currently check to see if a given warning is present but not that the
> index is not updated with the sparse entries. Add a new
> 'test_sparse_entry_unstaged' helper to be sure 'git add' is behaving
> correctly.
>
> We need to modify setup_sparse_entry to actually commit the sparse_entry
> file so it exists at HEAD and as an entry in the index, but its exact
> contents are not staged in the index.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
> t/t3705-add-sparse-checkout.sh | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh
> index 2b1fd0d0eef..e202a2ff74a 100755
> --- a/t/t3705-add-sparse-checkout.sh
> +++ b/t/t3705-add-sparse-checkout.sh
> @@ -19,6 +19,7 @@ setup_sparse_entry () {
> fi &&
> git add sparse_entry &&
> git update-index --skip-worktree sparse_entry &&
> + git commit --allow-empty -m "ensure sparse_entry exists at HEAD" &&
> SPARSE_ENTRY_BLOB=$(git rev-parse :sparse_entry)
> }
>
> @@ -36,6 +37,11 @@ setup_gitignore () {
> EOF
> }
>
> +test_sparse_entry_unstaged () {
> + git status --porcelain >actual &&
> + ! grep "^[MDARCU][M ] sparse_entry\$" actualDoes this say "we do not want any difference from the index, be it modification, deletion, addtion, etc."?
Just wondering if there were a reason why the pattern is more complex than "^[^ ][M ]" (i.e. anything but "unmodified since the index"), not necessarily suggesting to spell the test differently.
Thanks.