Re: [PATCH v4 0/2] stash show: learn --include-untracked and --only-untracked
flat view
From: Denton Liu <hidden>
Date: 2021-03-04 01:43:46
Possibly related (same subject, not in this thread)
- 2021-03-04 · [PATCH v4 0/2] stash show: learn --include-untracked and --only-untracked · Denton Liu <hidden>
On Wed, Mar 03, 2021 at 05:33:17PM -0800, Denton Liu wrote:
Hi Junio, On Wed, Mar 03, 2021 at 04:38:31PM -0800, Junio C Hamano wrote:quoted
Denton Liu [off-list ref] writes:quoted
A blindspot that I've noticed in git is that it's not possible to properly view a stash entry that has untracked files via `git stash show`. Teach `git stash show --include-untracked` which should do this. In addition, this series also teaches `--only-untracked` and the `stash.showIncludeUntracked` config option. This series is based on 'dl/stash-cleanup'. Changes since v3: * Incorporate Junio's SQUASH??? commits * Implement a custom unpack_trees() callback to detect the case where there are duplicate entries in worktree and untracked commitsI actually expected the latter enhancement to be done outside the scope of this series.
I decided to squash it into the current series because we have a lot of time until it will be merged (since it's definitely not going in now during the rc-period). If you'd like, though, I can reroll this series with the callback as a commit on top.
quoted hunk ↗ jump to hunk
quoted
I briefly looked at the callback but I am not convinced that it is correct (e.g. how do you notice and barf when the untracked tree records foo/bar.txt and the index or the working tree records foo as a file?).From my testing, the conflict is detected just fine. The following test-case should confirm it: -- >8 -- From: Denton Liu <redacted> Subject: [PATCH] fixup! stash show: teach --include-untracked and --only-untracked Signed-off-by: Denton Liu <redacted> --- t/t3905-stash-include-untracked.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index b470db7ef7..470aa65b44 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh@@ -405,4 +405,27 @@ test_expect_success 'stash show --include-untracked errors on duplicate files' ' test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err ' +test_expect_success 'stash show --include-untracked errors on directory/file conflict' ' + git reset --hard && + git clean -xf && + >tracked && + git add tracked && + tree=$(git write-tree) && + i_commit=$(git commit-tree -p HEAD -m "index on any-branch" "$tree") && + test_when_finished "rm -f untracked_index" && + u_commit=$( + GIT_INDEX_FILE="untracked_index" && + export GIT_INDEX_FILE && + rm tracked && + mkdir tracked && + >tracked/file && + git update-index --add tracked/file && + u_tree=$(git write-tree) && + git commit-tree -m "untracked files on any-branch" "$u_tree" + ) && + w_commit=$(git commit-tree -p HEAD -p "$i_commit" -p "$u_commit" -m "WIP on any-branch" "$tree") && + test_must_fail git stash show --include-untracked "$w_commit" 2>err && + test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err +' + test_done-- 2.31.0.rc1.228.gb75b4e4ce2