stash: introduce 'stash save --keep-index' option

'git stash save' saves local modifications to a new stash, and runs 'git
reset --hard' to revert them to a clean index and work tree.  When the
'--keep-index' option is specified, after that 'git reset --hard' the
previous contents of the index is restored and the work tree is updated
to match the index.  This option is useful if the user wants to commit
only parts of his local modifications, but wants to test those parts
before committing.

Also add support for the completion of the new option, and add an
example use case to the documentation.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
SZEDER Gábor
2008-06-27 16:37:15 +02:00
committed by Junio C Hamano
parent 6991357513
commit 7bedebcaad
3 changed files with 51 additions and 6 deletions

View File

@ -1137,8 +1137,19 @@ _git_show ()
_git_stash ()
{
local subcommands='save list show apply clear drop pop create'
if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
else
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$subcommand,$cur" in
save,--*)
__gitcomp "--keep-index"
;;
*)
COMPREPLY=()
;;
esac
fi
}