{"thread":{"id":"61989","subject":"[PATCH] builtin/stash: test push with new file added and removed","startedAt":"2024-08-21T19:09:40Z","lastAt":"2024-08-21T19:09:40Z","messageCount":1,"participants":["Piotr Siupa"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"501459","messageId":"20240821190921.18772-1-piotrsiupa@gmail.com","threadId":"61989","inReplyTo":null,"subject":"[PATCH] builtin/stash: test push with new file added and removed","fromName":"Piotr Siupa","fromEmail":"piotrsiupa@gmail.com","sentAt":"2024-08-21T19:09:21Z","receivedAt":"2024-08-21T19:09:40Z","isPatch":true,"sender":{"key":"piotrsiupa@gmail.com","avatar":"https://gravatar.com/avatar/5970da465a147bda2b821a29e966ed328cca93067a42d05cf33ee38aac4acd6f?d=mp&s=160"},"body":"In the scenario when a new file is added to index, then it is deleted\nfrom the workspace, and then a stash is created, the information about\nthe deletion is lost.\nThe resulting stash contains the file but not the information that it\nwas deleted. The file is also back in the workspace after the push.\n\nThis commit adds a test for such scenario (as a known breakage).\n\nSigned-off-by: Piotr Siupa <piotrsiupa@gmail.com>\n---\n t/t3903-stash.sh | 31 +++++++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex a7f71f8126..84f0309b3d 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -469,6 +469,37 @@ test_expect_success 'stash rm and ignore (stage .gitignore)' '\n \ttest file = \"$(cat .gitignore)\"\n '\n \n+test_expect_failure 'stash add and rm' '\n+\ttest_when_finished \"rm -rf add_and_rm\" &&\n+\tgit init add_and_rm &&\n+\t(\n+\t\tcd add_and_rm &&\n+\t\tgit commit --allow-empty --message init &&\n+\n+\t\t# create a stash with \"file\" ONLY in the index\n+\t\techo content >file &&\n+\t\tgit add file &&\n+\t\trm file &&\n+\t\tgit stash &&\n+\t\t# no reason for the file to reappear but is will not hurt to check\n+\t\ttest_path_is_missing file &&\n+\n+\t\t# apply the stash without \"--index\"\n+\t\t# it should behave as if \"file\" was not in the stash\n+\t\tgit stash apply &&\n+\t\ttest_path_is_missing file &&\n+\t\ttest_must_fail git restore file &&\n+\n+\t\t# apply the stash with \"--index\"\n+\t\t# it should restore \"file\" in index but not in workspace\n+\t\tgit stash apply --index &&\n+\t\ttest_path_is_missing file &&\n+\t\tgit restore file &&\n+\t\techo content >expect &&\n+\t\ttest_cmp expect file\n+\t)\n+'\n+\n test_expect_success SYMLINKS 'stash file to symlink' '\n \tgit reset --hard &&\n \trm file &&\n-- \n2.34.1\n\n"}]}