]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t9902-completion.sh
completion: handle '!f() { ... }; f' and "!sh -c '...' -" aliases
[thirdparty/git.git] / t / t9902-completion.sh
index 2d4beb5e50c257fed2f4b6475cb5834425b5a64f..1d1c1063a38866f1792f9b451a4942d06c91edb4 100755 (executable)
@@ -550,6 +550,33 @@ test_expect_success 'complete files' '
        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' '
        git init tmp && cd tmp &&
        test_when_finished "cd .. && rm -rf tmp" &&