Merge branch 'sp/complete-ext-alias'
* sp/complete-ext-alias: completion: handle '!f() { ... }; f' and "!sh -c '...' -" aliases
This commit is contained in:
commit
af6ba0eb9e
@ -21,6 +21,12 @@
|
|||||||
# source ~/.git-completion.sh
|
# source ~/.git-completion.sh
|
||||||
# 3) Consider changing your PS1 to also show the current branch,
|
# 3) Consider changing your PS1 to also show the current branch,
|
||||||
# see git-prompt.sh for details.
|
# see git-prompt.sh for details.
|
||||||
|
#
|
||||||
|
# If you use complex aliases of form '!f() { ... }; f', you can use the null
|
||||||
|
# command ':' as the first command in the function body to declare the desired
|
||||||
|
# completion style. For example '!f() { : git commit ; ... }; f' will
|
||||||
|
# tell the completion to use commit completion. This also works with aliases
|
||||||
|
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
|
||||||
|
|
||||||
case "$COMP_WORDBREAKS" in
|
case "$COMP_WORDBREAKS" in
|
||||||
*:*) : great ;;
|
*:*) : great ;;
|
||||||
@ -781,6 +787,10 @@ __git_aliased_command ()
|
|||||||
-*) : option ;;
|
-*) : option ;;
|
||||||
*=*) : setting env ;;
|
*=*) : setting env ;;
|
||||||
git) : git itself ;;
|
git) : git itself ;;
|
||||||
|
\(\)) : skip parens of shell function definition ;;
|
||||||
|
{) : skip start of shell helper function ;;
|
||||||
|
:) : skip null command ;;
|
||||||
|
\'*) : skip opening quote after sh -c ;;
|
||||||
*)
|
*)
|
||||||
echo "$word"
|
echo "$word"
|
||||||
return
|
return
|
||||||
|
@ -550,6 +550,33 @@ test_expect_success 'complete files' '
|
|||||||
test_completion "git add mom" "momified"
|
test_completion "git add mom" "momified"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cmd> ...'" '
|
||||||
|
test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
|
||||||
|
test_completion "git co m" <<-\EOF
|
||||||
|
master Z
|
||||||
|
mybranch Z
|
||||||
|
mytag Z
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'completion uses <cmd> completion for alias: !f () { VAR=val git <cmd> ... }' '
|
||||||
|
test_config alias.co "!f () { VAR=val git checkout ... ; } f" &&
|
||||||
|
test_completion "git co m" <<-\EOF
|
||||||
|
master Z
|
||||||
|
mybranch Z
|
||||||
|
mytag Z
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'completion used <cmd> completion for alias: !f() { : git <cmd> ; ... }' '
|
||||||
|
test_config alias.co "!f() { : git checkout ; if ... } f" &&
|
||||||
|
test_completion "git co m" <<-\EOF
|
||||||
|
master Z
|
||||||
|
mybranch Z
|
||||||
|
mytag Z
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_failure 'complete with tilde expansion' '
|
test_expect_failure 'complete with tilde expansion' '
|
||||||
git init tmp && cd tmp &&
|
git init tmp && cd tmp &&
|
||||||
test_when_finished "cd .. && rm -rf tmp" &&
|
test_when_finished "cd .. && rm -rf tmp" &&
|
||||||
|
Loading…
Reference in New Issue
Block a user