]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
stash show: teach --include-untracked and --only-untracked
authorDenton Liu <liu.denton@gmail.com>
Wed, 3 Mar 2021 11:16:42 +0000 (03:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2021 22:31:26 +0000 (14:31 -0800)
commitd3c7bf73bdb679dd98c6aff65edbce4df743ddd3
tree7e4757674006ff07cfe29906afdc6bb8f0ec8aea
parent3e885f02775dad0d907d447bc3c24fa07870b41f
stash show: teach --include-untracked and --only-untracked

Stash entries can be made with untracked files via
`git stash push --include-untracked`. However, because the untracked
files are stored in the third parent of the stash entry and not the
stash entry itself, running `git stash show` does not include the
untracked files as part of the diff.

With --include-untracked, untracked paths, which are recorded in the
third-parent if it exists, are shown in addition to the paths that have
modifications between the stash base and the working tree in the stash.

It is possible to manually craft a malformed stash entry where duplicate
untracked files in the stash entry will mask tracked files. We detect
and error out in that case via a custom unpack_trees() callback:
stash_worktree_untracked_merge().

Also, teach stash the --only-untracked option which only shows the
untracked files of a stash entry. This is similar to `git show stash^3`
but it is nice to provide a convenient abstraction for it so that users
do not have to think about the underlying implementation.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-stash.txt
builtin/stash.c
contrib/completion/git-completion.bash
t/t3905-stash-include-untracked.sh
unpack-trees.c
unpack-trees.h