diff options
Diffstat (limited to 't/t9902-completion.sh')
-rwxr-xr-x | t/t9902-completion.sh | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index a1c4f1f6d4..518203fbe0 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -5,6 +5,9 @@ test_description='test bash completion' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-bash.sh complete () @@ -537,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' ' EOF ' +test_expect_success '__gitcomp - equal skip' ' + test_gitcomp "--option=" "--option=" <<-\EOF && + + EOF + test_gitcomp "option=" "option=" <<-\EOF + + EOF +' + test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' __gitcomp "$invalid_variable_name" ' @@ -1876,6 +1888,7 @@ test_expect_success '__git_find_on_cmdline - single match' ' ( words=(git command --opt list) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_cmp expect actual @@ -1886,6 +1899,7 @@ test_expect_success '__git_find_on_cmdline - multiple matches' ' ( words=(git command -o --opt remove list add) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_cmp expect actual @@ -1895,6 +1909,7 @@ test_expect_success '__git_find_on_cmdline - no match' ' ( words=(git command --opt branch) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_must_be_empty actual @@ -1905,6 +1920,7 @@ test_expect_success '__git_find_on_cmdline - single match with index' ' ( words=(git command --opt list) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_cmp expect actual @@ -1915,6 +1931,7 @@ test_expect_success '__git_find_on_cmdline - multiple matches with index' ' ( words=(git command -o --opt remove list add) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_cmp expect actual @@ -1924,11 +1941,23 @@ test_expect_success '__git_find_on_cmdline - no match with index' ' ( words=(git command --opt branch) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_must_be_empty actual ' +test_expect_success '__git_find_on_cmdline - ignores matches before command with index' ' + echo "6 remove" >expect && + ( + words=(git -C remove command -o --opt remove list add) && + cword=${#words[@]} && + __git_cmd_idx=3 && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + test_expect_success '__git_get_config_variables' ' cat >expect <<-EOF && name-1 @@ -2119,6 +2148,9 @@ test_expect_success PERL 'send-email' ' --cover-from-description=Z --cover-letter Z EOF + test_completion "git send-email --val" <<-\EOF && + --validate Z + EOF test_completion "git send-email ma" "main " ' @@ -2272,6 +2304,7 @@ do ( words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && + __git_cmd_idx=1 && __git_complete_remote_or_refspec && print_comp ) && @@ -2285,6 +2318,7 @@ do ( words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && + __git_cmd_idx=1 && __git_complete_remote_or_refspec && print_comp ) && @@ -2303,6 +2337,7 @@ test_expect_success 'git config - variable name' ' test_completion "git config log.d" <<-\EOF log.date Z log.decorate Z + log.diffMerges Z EOF ' @@ -2324,6 +2359,7 @@ test_expect_success 'git -c - variable name' ' test_completion "git -c log.d" <<-\EOF log.date=Z log.decorate=Z + log.diffMerges=Z EOF ' @@ -2345,6 +2381,7 @@ test_expect_success 'git clone --config= - variable name' ' test_completion "git clone --config=log.d" <<-\EOF log.date=Z log.decorate=Z + log.diffMerges=Z EOF ' @@ -2355,6 +2392,12 @@ test_expect_success 'git clone --config= - value' ' EOF ' +test_expect_success 'options with value' ' + test_completion "git merge -X diff-algorithm=" <<-\EOF + + EOF +' + test_expect_success 'sourcing the completion script clears cached commands' ' __git_compute_all_commands && verbose test -n "$__git_all_commands" && @@ -2363,7 +2406,6 @@ test_expect_success 'sourcing the completion script clears cached commands' ' ' test_expect_success 'sourcing the completion script clears cached merge strategies' ' - GIT_TEST_GETTEXT_POISON=false && __git_compute_merge_strategies && verbose test -n "$__git_merge_strategies" && . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" && @@ -2380,4 +2422,37 @@ test_expect_success 'sourcing the completion script clears cached --options' ' verbose test -z "$__gitcomp_builtin_notes_edit" ' +test_expect_success 'option aliases are not shown by default' ' + test_completion "git clone --recurs" "--recurse-submodules " +' + +test_expect_success 'option aliases are shown with GIT_COMPLETION_SHOW_ALL' ' + . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" && + GIT_COMPLETION_SHOW_ALL=1 && export GIT_COMPLETION_SHOW_ALL && + test_completion "git clone --recurs" <<-\EOF + --recurse-submodules Z + --recursive Z + EOF +' + +test_expect_success '__git_complete' ' + unset -f __git_wrap__git_main && + + __git_complete foo __git_main && + __git_have_func __git_wrap__git_main && + unset -f __git_wrap__git_main && + + __git_complete gf _git_fetch && + __git_have_func __git_wrap_git_fetch && + + __git_complete foo git && + __git_have_func __git_wrap__git_main && + unset -f __git_wrap__git_main && + + __git_complete gd git_diff && + __git_have_func __git_wrap_git_diff && + + test_must_fail __git_complete ga missing +' + test_done |