From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: matheus.bernardino@usp.br, dstolee@microsoft.com,
Elijah Newren <newren@gmail.com>,
Elijah Newren <newren@gmail.com>
Subject: [PATCH 1/3] t7012: add a testcase demonstrating stash apply bugs in sparse checkouts
Date: Fri, 20 Nov 2020 16:53:40 +0000 [thread overview]
Message-ID: <de4b4d207b41c82718896f8e65dae663abd8e0bb.1605891222.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.919.git.git.1605891222.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>
Applying stashes in sparse-checkouts, particularly when the patterns
used to define the present paths have changed between when the stash was
created and when it is applied, has a number of bugs. The primary
problem is perhaps that stashes can be only partially applied (sometimes
without any warning or error being displayed and with 0 exit status).
In addition, there are cases where partial stash application comes with
non-translated error messages and an early abort. The first is when
there are files present despite the SKIP_WORKTREE bit being set, in
which case the error message shown is:
error: Entry 'PATHNAME' not uptodate. Cannot merge.
The other situation is when a stash contains new files to add to the
working tree; in this case, the code aborts early (but after at least
partial stash application) with the following error message being shown:
error: NEWFILE: does not exist and --remove not passed
fatal: Unable to process path NEWFILE
Add a test that can trigger all three of these problems that carefully
checks that the working copy and SKIP_WORKTREE bits are as expected
after the stash application...but currently marked as expected to fail.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
t/t7012-skip-worktree-writing.sh | 88 ++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh
index 7476781979..a184ee97fb 100755
--- a/t/t7012-skip-worktree-writing.sh
+++ b/t/t7012-skip-worktree-writing.sh
@@ -149,6 +149,94 @@ test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' '
--diff-filter=D -- keep-me.t
'
+test_expect_failure 'stash restore in sparse checkout' '
+ test_create_repo stash-restore &&
+ (
+ cd stash-restore &&
+
+ mkdir subdir &&
+ echo A >subdir/A &&
+ echo untouched >untouched &&
+ echo removeme >removeme &&
+ echo modified >modified &&
+ git add . &&
+ git commit -m Initial &&
+
+ echo AA >>subdir/A &&
+ echo addme >addme &&
+ echo tweaked >>modified &&
+ rm removeme &&
+ git add addme &&
+
+ git stash push &&
+
+ git sparse-checkout set subdir &&
+
+ # Ensure after sparse-checkout we only have expected files
+ cat >expect <<-EOF &&
+ S modified
+ S removeme
+ H subdir/A
+ S untouched
+ EOF
+ git ls-files -t >actual &&
+ test_cmp expect actual &&
+
+ test_path_is_missing addme &&
+ test_path_is_missing modified &&
+ test_path_is_missing removeme &&
+ test_path_is_file subdir/A &&
+ test_path_is_missing untouched &&
+
+ # Put a file in the working directory in the way
+ echo in the way >modified &&
+ git stash apply &&
+
+ # Ensure stash vivifies modifies paths...
+ cat >expect <<-EOF &&
+ H addme
+ H modified
+ H removeme
+ H subdir/A
+ S untouched
+ EOF
+ git ls-files -t >actual &&
+ test_cmp expect actual &&
+
+ # ...and that the paths show up in status as changed...
+ cat >expect <<-EOF &&
+ A addme
+ M modified
+ D removeme
+ M subdir/A
+ ?? actual
+ ?? expect
+ ?? modified.stash.XXXXXX
+ EOF
+ git status --porcelain | \
+ sed -e s/stash......./stash.XXXXXX/ >actual &&
+ test_cmp expect actual &&
+
+ # ...and that working directory reflects the files correctly
+ test_path_is_file addme &&
+ test_path_is_file modified &&
+ test_path_is_missing removeme &&
+ test_path_is_file subdir/A &&
+ test_path_is_missing untouched &&
+
+ # ...including that we have the expected "modified" file...
+ cat >expect <<-EOF &&
+ modified
+ tweaked
+ EOF
+ test_cmp expect modified &&
+
+ # ...and that the other "modified" file is still present...
+ echo in the way >expect &&
+ test_cmp expect modified.stash.*
+ )
+'
+
#TODO test_expect_failure 'git-apply adds file' false
#TODO test_expect_failure 'git-apply updates file' false
#TODO test_expect_failure 'git-apply removes file' false
--
gitgitgadget
next prev parent reply other threads:[~2020-11-20 17:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 16:53 [PATCH 0/3] Fix stash apply in sparse checkouts (and a submodule test) Elijah Newren via GitGitGadget
2020-11-20 16:53 ` Elijah Newren via GitGitGadget [this message]
2020-11-20 16:53 ` [PATCH 2/3] stash: remove unnecessary process forking Elijah Newren via GitGitGadget
2020-11-20 16:53 ` [PATCH 3/3] stash: fix stash application in sparse-checkouts Elijah Newren via GitGitGadget
2020-11-21 12:47 ` Chris Torek
2020-11-22 3:47 ` Elijah Newren
2020-11-25 22:14 ` [PATCH 0/3] Fix stash apply in sparse checkouts (and a submodule test) Junio C Hamano
2020-11-26 5:31 ` Elijah Newren
2020-12-01 22:25 ` [PATCH v2 " Elijah Newren via GitGitGadget
2020-12-01 22:25 ` [PATCH v2 1/3] t7012: add a testcase demonstrating stash apply bugs in sparse checkouts Elijah Newren via GitGitGadget
2020-12-01 22:25 ` [PATCH v2 2/3] stash: remove unnecessary process forking Elijah Newren via GitGitGadget
2020-12-01 23:02 ` Junio C Hamano
2020-12-02 16:09 ` Elijah Newren
2020-12-01 22:25 ` [PATCH v2 3/3] stash: fix stash application in sparse-checkouts Elijah Newren via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de4b4d207b41c82718896f8e65dae663abd8e0bb.1605891222.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=matheus.bernardino@usp.br \
--cc=newren@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).