[PATCH] builtin/stash: test push with new file added and removed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the scenario when a new file is added to index, then it is deleted
from the workspace, and then a stash is created, the information about
the deletion is lost.
The resulting stash contains the file but not the information that it
was deleted. The file is also back in the workspace after the push.

This commit adds a test for such scenario (as a known breakage).

Signed-off-by: Piotr Siupa <piotrsiupa@xxxxxxxxx>
---
 t/t3903-stash.sh | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index a7f71f8126..84f0309b3d 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -469,6 +469,37 @@ test_expect_success 'stash rm and ignore (stage .gitignore)' '
 	test file = "$(cat .gitignore)"
 '
 
+test_expect_failure 'stash add and rm' '
+	test_when_finished "rm -rf add_and_rm" &&
+	git init add_and_rm &&
+	(
+		cd add_and_rm &&
+		git commit --allow-empty --message init &&
+
+		# create a stash with "file" ONLY in the index
+		echo content >file &&
+		git add file &&
+		rm file &&
+		git stash &&
+		# no reason for the file to reappear but is will not hurt to check
+		test_path_is_missing file &&
+
+		# apply the stash without "--index"
+		# it should behave as if "file" was not in the stash
+		git stash apply &&
+		test_path_is_missing file &&
+		test_must_fail git restore file &&
+
+		# apply the stash with "--index"
+		# it should restore "file" in index but not in workspace
+		git stash apply --index &&
+		test_path_is_missing file &&
+		git restore file &&
+		echo content >expect &&
+		test_cmp expect file
+	)
+'
+
 test_expect_success SYMLINKS 'stash file to symlink' '
 	git reset --hard &&
 	rm file &&
-- 
2.34.1





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux