* [PATCH] builtin/stash: test push with new file added and removed
@ 2024-08-21 19:09 Piotr Siupa
0 siblings, 0 replies; only message in thread
From: Piotr Siupa @ 2024-08-21 19:09 UTC (permalink / raw)
To: git; +Cc: gitster, ps, Piotr Siupa
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@gmail.com>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-08-21 19:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 19:09 [PATCH] builtin/stash: test push with new file added and removed Piotr Siupa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).