From: Piotr Siupa <piotrsiupa@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, ps@pks.im, Piotr Siupa <piotrsiupa@gmail.com>
Subject: [PATCH] builtin/stash: test push with new file added and removed
Date: Wed, 21 Aug 2024 21:09:21 +0200 [thread overview]
Message-ID: <20240821190921.18772-1-piotrsiupa@gmail.com> (raw)
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
reply other threads:[~2024-08-21 19:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240821190921.18772-1-piotrsiupa@gmail.com \
--to=piotrsiupa@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).