Subject: Re: [PATCH v4 1/7] t7063: more thorough status checking

From: Derrick Stolee <[email-masked]>
Date: Fri, 27 Mar 2020 09:09:19 -0400

On 3/26/2020 5:27 PM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <[email-masked]>
> 
> It turns out the t7063 has some testcases that even without using the
> untracked cache cover situations that nothing else in the testsuite
> handles.  Checking the results of
>   git status --porcelain
> both with and without the untracked cache, and comparing both against
> our expected results helped uncover a critical bug in some dir.c
> restructuring.
> 
> Unfortunately, it's not easy to run status and tell it to ignore the
> untracked cache; the only knob we have it to instruct it to *delete*
> (and ignore) the untracked cache.
> 
> Create a simple helper that will create a clone of the index that is
> missing the untracked cache bits, and use it to compare that the results
> with the untracked cache match the results we get without the untracked
> cache.
> 
> Signed-off-by: Elijah Newren <[email-masked]>
> ---
>  t/t7063-status-untracked-cache.sh | 52 +++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh
> index 190ae149cf3..156d06c34e8 100755
> --- a/t/t7063-status-untracked-cache.sh
> +++ b/t/t7063-status-untracked-cache.sh
> @@ -30,6 +30,30 @@ status_is_clean() {
>  	test_must_be_empty ../status.actual
>  }
>  
> +# Ignore_Untracked_Cache, abbreviated to 3 letters because then people can
> +# compare commands side-by-side, e.g.
> +#    iuc status --porcelain >expect &&
> +#    git status --porcelain >actual &&
> +#    test_cmp expect actual
> +iuc() {
> +	git ls-files -s >../current-index-entries
> +	git ls-files -t | grep ^S | sed -e s/^S.// >../current-sparse-entries
> +
> +	GIT_INDEX_FILE=.git/tmp_index
> +	export GIT_INDEX_FILE
> +	git update-index --index-info <../current-index-entries
> +	git update-index --skip-worktree $(cat ../current-sparse-entries)
> +
> +	git -c core.untrackedCache=false "$@"
> +	ret=$?
> +
> +	rm ../current-index-entries
> +	rm $GIT_INDEX_FILE
> +	unset GIT_INDEX_FILE
> +
> +	return $ret
> +}

This is a clever way to get around the untracked cache deletion.

Thanks for adding these extra comparisons! It really does help guarantee
that we are doing the right thing in each case.

-Stolee