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>
This commit is contained in:

committed by
Junio C Hamano

parent
3e885f0277
commit
d3c7bf73bd
@ -9,7 +9,7 @@ SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git stash' list [<log-options>]
|
||||
'git stash' show [<diff-options>] [<stash>]
|
||||
'git stash' show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]
|
||||
'git stash' drop [-q|--quiet] [<stash>]
|
||||
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
|
||||
'git stash' branch <branchname> [<stash>]
|
||||
@ -83,7 +83,7 @@ stash@{1}: On master: 9cc0589... Add git-stash
|
||||
The command takes options applicable to the 'git log'
|
||||
command to control what is shown and how. See linkgit:git-log[1].
|
||||
|
||||
show [<diff-options>] [<stash>]::
|
||||
show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]::
|
||||
|
||||
Show the changes recorded in the stash entry as a diff between the
|
||||
stashed contents and the commit back when the stash entry was first
|
||||
@ -160,10 +160,18 @@ up with `git clean`.
|
||||
|
||||
-u::
|
||||
--include-untracked::
|
||||
This option is only valid for `push` and `save` commands.
|
||||
--no-include-untracked::
|
||||
When used with the `push` and `save` commands,
|
||||
all untracked files are also stashed and then cleaned up with
|
||||
`git clean`.
|
||||
+
|
||||
All untracked files are also stashed and then cleaned up with
|
||||
`git clean`.
|
||||
When used with the `show` command, show the untracked files in the stash
|
||||
entry as part of the diff.
|
||||
|
||||
--only-untracked::
|
||||
This option is only valid for the `show` command.
|
||||
+
|
||||
Show only the untracked files in the stash entry as part of the diff.
|
||||
|
||||
--index::
|
||||
This option is only valid for `pop` and `apply` commands.
|
||||
|
Reference in New Issue
Block a user