Merge branch 'nd/switch-and-restore'
Two new commands "git switch" and "git restore" are introduced to split "checking out a branch to work on advancing its history" and "checking out paths out of the index and/or a tree-ish to work on advancing the current history" out of the single "git checkout" command. * nd/switch-and-restore: (46 commits) completion: disable dwim on "git switch -d" switch: allow to switch in the middle of bisect t2027: use test_must_be_empty Declare both git-switch and git-restore experimental help: move git-diff and git-reset to different groups doc: promote "git restore" user-manual.txt: prefer 'merge --abort' over 'reset --hard' completion: support restore t: add tests for restore restore: support --patch restore: replace --force with --ignore-unmerged restore: default to --source=HEAD when only --staged is specified restore: reject invalid combinations with --staged restore: add --worktree and --staged checkout: factor out worktree checkout code restore: disable overlay mode by default restore: make pathspec mandatory restore: take tree-ish from --source option instead checkout: split part of it to new command 'restore' doc: promote "git switch" ...
This commit is contained in:
@ -37,7 +37,8 @@
|
||||
# GIT_COMPLETION_CHECKOUT_NO_GUESS
|
||||
#
|
||||
# When set to "1", do not include "DWIM" suggestions in git-checkout
|
||||
# completion (e.g., completing "foo" when "origin/foo" exists).
|
||||
# and git-switch completion (e.g., completing "foo" when "origin/foo"
|
||||
# exists).
|
||||
|
||||
case "$COMP_WORDBREAKS" in
|
||||
*:*) : great ;;
|
||||
@ -2160,6 +2161,44 @@ _git_status ()
|
||||
__git_complete_index_file "$complete_opt"
|
||||
}
|
||||
|
||||
_git_switch ()
|
||||
{
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin switch
|
||||
;;
|
||||
*)
|
||||
# check if --track, --no-track, or --no-guess was specified
|
||||
# if so, disable DWIM mode
|
||||
local track_opt="--track" only_local_ref=n
|
||||
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
|
||||
[ -n "$(__git_find_on_cmdline "--track --no-track --no-guess")" ]; then
|
||||
track_opt=''
|
||||
fi
|
||||
# explicit --guess enables DWIM mode regardless of
|
||||
# $GIT_COMPLETION_CHECKOUT_NO_GUESS
|
||||
if [ -n "$(__git_find_on_cmdline "--guess")" ]; then
|
||||
track_opt='--track'
|
||||
fi
|
||||
if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then
|
||||
only_local_ref=y
|
||||
else
|
||||
# --guess --detach is invalid combination, no
|
||||
# dwim will be done when --detach is specified
|
||||
track_opt=
|
||||
fi
|
||||
if [ $only_local_ref = y -a -z "$track_opt" ]; then
|
||||
__gitcomp_direct "$(__git_heads "" "$cur" " ")"
|
||||
else
|
||||
__git_complete_refs $track_opt
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_config_get_set_variables ()
|
||||
{
|
||||
local prevword word config_file= c=$cword
|
||||
@ -2458,6 +2497,21 @@ _git_reset ()
|
||||
__git_complete_refs
|
||||
}
|
||||
|
||||
_git_restore ()
|
||||
{
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--source=*)
|
||||
__git_complete_refs --cur="${cur##--source=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin restore
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_revert_inprogress_options="--continue --quit --abort"
|
||||
|
||||
_git_revert ()
|
||||
|
Reference in New Issue
Block a user