[PATCH v3 3/5] t3903: test stash --index merges
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Sep 26, 2026, 12:16 UTC
- Message-ID
- <8b5ea5e6f47ee9a57df3a4d97a457d024b3dec00.1790425008.git.ben.knoble@gmail.com>
- In-Reply-To
- <cover.1790425008.git.ben.knoble@gmail.com>
A future commit will refactor index handling for applied stashes, and we need to take care to get the order of trees right when merging. Add a test that covers this case.
Suggested-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: D. Ben Knoble <ben.knoble@gmail.com> --- t/t3903-stash.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 721158606f..9bc99fa252 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -374,6 +374,27 @@ setup_stash() { test_cmp expect actual ' +# the later "stash -k" test is not expecting us to muck with file so much, so +# reset when finished +test_expect_success 'stash apply --index merges the correct trees' ' + head=$(git rev-parse HEAD) && + test_when_finished "git reset --hard $head" && + test_write_lines A B C >file && + git commit -m setup file && + test_write_lines A B staged >file && + git add file && + test_write_lines A B unstaged >file && + git stash && + test_write_lines committed B C >file && + git commit -m to-be-merged file && + git stash pop --index && + git show :file >actual && + test_write_lines committed B staged >expect && + test_cmp expect actual && + test_write_lines committed B unstaged >expect && + test_cmp expect file +' + test_expect_success 'stash -k' ' echo bar3 >file && echo bar4 >file2 &&
-- 2.56.0.rc1.315.gc6ed9934b7.dirty