This series is based on en/sparse-checkout-set. It updates custom tab completion for the sparse-checkout command. Specifically, it corrects the following issues with the current method: 1. git sparse-checkout <TAB> results in an incomplete list of subcommands (it is missing reapply and add). 2. git sparse-checkout --<TAB> does not complete the help option. 3. Options for subcommands are not tab-completable. 4. git sparse-checkout set <TAB> and git sparse-checkout add <TAB> show both file names and directory names. The first commit in this series is a set of failing tests that highlight each of the above issues. The next commit updates the _git_sparse_checkout method in git-completion.bash to enable each of these tests to pass. Changes since V1 ================ * Rebase onto en/sparse-checkout-set. * Add subcommand options (including --no-cone) for set and reapply. * Extend 'sparse-checkout completes subcommand options' test to validate new set/reapply subcommand options. * No longer set index.sparse to false in 'sparse-checkout completes directory names' test. Thanks, Lessley Lessley Dennington (2): sparse-checkout: custom tab completion tests sparse-checkout: custom tab completion contrib/completion/git-completion.bash | 38 ++++++++---- t/t9902-completion.sh | 85 ++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 12 deletions(-) base-commit: dfac9b609f86cd4f6ce896df9e1172d2a02cde48 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1108%2Fldennington%2Fsparse-checkout-bash-completion-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1108/ldennington/sparse-checkout-bash-completion-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/1108 Range-diff vs v1: 1: a7f3ae5cdda ! 1: 955fcab0052 sparse-checkout: custom tab completion tests @@ t/t9902-completion.sh: test_expect_success 'git checkout - with --detach, comple +test_expect_failure 'sparse-checkout completes subcommand options' ' + test_completion "git sparse-checkout init --" <<-\EOF && + --cone Z ++ --no-cone Z + --sparse-index Z + --no-sparse-index Z + EOF + + test_completion "git sparse-checkout set --" <<-\EOF && ++ --cone Z ++ --no-cone Z ++ --sparse-index Z ++ --no-sparse-index Z + --stdin Z + EOF + ++ test_completion "git sparse-checkout reapply --" <<-\EOF && ++ --cone Z ++ --no-cone Z ++ --sparse-index Z ++ --no-sparse-index Z ++ EOF ++ + test_completion "git sparse-checkout add --" <<-\EOF + --stdin Z + EOF @@ t/t9902-completion.sh: test_expect_success 'git checkout - with --detach, comple + ) && + + # initialize sparse-checkout definitions -+ git -C sparse-checkout config index.sparse false && + git -C sparse-checkout sparse-checkout init --cone && + git -C sparse-checkout sparse-checkout set folder1/0 folder3 && + 2: ab51236d18c ! 2: cecf501e076 sparse-checkout: custom tab completion @@ contrib/completion/git-completion.bash: _git_show_branch () __git_complete_revlist } -+__git_sparse_checkout_init_opts="--cone --sparse-index --no-sparse-index" ++__git_sparse_checkout_subcommand_opts="--cone --no-cone --sparse-index --no-sparse-index" + _git_sparse_checkout () { @@ contrib/completion/git-completion.bash: _git_show_branch () - *) - ;; + case "$prev" in -+ init) -+ __gitcomp "$__git_sparse_checkout_init_opts" ++ set) ++ __gitcomp "$__git_sparse_checkout_subcommand_opts --stdin" ++ __gitcomp "$(git ls-tree -d -r HEAD --name-only)" + ;; -+ add|set) ++ add) + __gitcomp "--stdin" + __gitcomp "$(git ls-tree -d -r HEAD --name-only)" + ;; ++ init|reapply) ++ __gitcomp "$__git_sparse_checkout_subcommand_opts" ++ ;; + *) + ;; esac @@ t/t9902-completion.sh: test_expect_failure 'sparse-checkout completes subcommand +test_expect_success 'sparse-checkout completes subcommand options' ' test_completion "git sparse-checkout init --" <<-\EOF && --cone Z - --sparse-index Z + --no-cone Z @@ t/t9902-completion.sh: test_expect_failure 'sparse-checkout completes subcommand options' ' EOF ' -- gitgitgadget