Re: [PATCH v2 3/4] t: test failed "stash apply --index"
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Sep 24, 2026, 09:42 UTC
- Message-ID
- <232f2bf6-04d8-4a54-b4e9-51b5ee79799f@gmail.com>
- In-Reply-To
- <5bd4b78cace8ba8c8887c78f739bde3513dfda28.1790168285.git.ben.knoble@gmail.com>
Hi Ben
On 23/09/2026 13:58, D. Ben Knoble wrote:
Show 25 quoted lines
> The next commit will refactor index handling for applied stashes, so
> let's make sure we cover conflicted index merging, too.
>
> Signed-off-by: D. Ben Knoble <ben.knoble@gmail.com>
> ---
> t/t3903-stash.sh | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index 721158606f..3958ab3c8d 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -374,6 +374,24 @@ setup_stash() {
> test_cmp expect actual
> '
>
> +test_expect_success 'stash apply --index leaves everything untouched on failure' '
> + git reset --hard &&
> + echo test >other-file &&
> + git add other-file &&
> + git stash &&
> + echo unrelated >file &&
> + echo unrelated >another-file &&
> + git add another-file &&
> + git diff-files >expect &&diff-files shows the worktree blobs as null object ids, so comparing this before and after stashing only tells us that the same set of files have unstaged changes, not that the unstaged changes are the same. Adding "-p" would check the worktree files are unchanged.
> + echo conflict >other-file && > + git add other-file &&
I wonder if we should to add "git diff-index --cached HEAD >expect-index" here so we can check the index is unchanged as well. For the paths that have unstaged changes we're already checking the index object ids via "diff-files", but I think in theory it would be possible to have an identical change in the index and worktree that is not picked up by that.
Thanks for adding this test, it is a useful improvement in our coverage.
Phillip
Show 9 quoted lines
> + test_must_fail git stash apply --index 2>err && > + test_grep "conflicts in index. Try without --index" err && > + git diff-files >actual && > + test_cmp expect actual > +' > + > test_expect_success 'stash -k' ' > echo bar3 >file && > echo bar4 >file2 &&