On 12/29/2021 7:32 PM, Lessley Dennington via GitGitGadget wrote: > From: Lessley Dennington <lessleydennington@xxxxxxxxx> > > Add tests for missing/incorrect components of custom tab completion for the > sparse-checkout command. These tests specifically highlight the following: > > 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. Thanks for these. I've never looked at this test script before, but I can surmise how it works from your tests. > Although these tests currently fail, they will succeed with the > sparse-checkout modifications in git-completion.bash in the next commit in > this series. > +test_expect_failure 'sparse-checkout completes subcommand options' ' > + test_completion "git sparse-checkout init --" <<-\EOF && > + --cone Z > + --sparse-index Z > + --no-sparse-index Z > + EOF > + > + test_completion "git sparse-checkout set --" <<-\EOF && > + --stdin Z In en/sparse-checkout-set, the 'set' subcommand learns the options for init, including --cone, --sparse-index, and --no-sparse-index. I think technically, --no-cone is in there, too. Further, the 'reapply' subcommand learns these options in that series and I see you do not include that subcommand in this test. You might want to rebase onto en/sparse-checkout-set and adjust these tests for the new options (plus change the next patch that implements the completion). > + EOF > + > + test_completion "git sparse-checkout add --" <<-\EOF > + --stdin Z > + EOF > +' > +test_expect_failure 'sparse-checkout completes directory names' ' > + # set up sparse-checkout repo > + git init sparse-checkout && > + ( > + cd sparse-checkout && > + mkdir -p folder1/0/1 folder2/0 folder3 && > + touch folder1/0/1/t.txt && > + touch folder2/0/t.txt && > + touch folder3/t.txt && > + git add . && > + git commit -am "Initial commit" > + ) && > + > + # initialize sparse-checkout definitions > + git -C sparse-checkout config index.sparse false && I'm guessing that the implementation actually requires this, but I'll take a look in the next patch. It might just be slow to expand the full list of directories in the sparse index case. > + git -C sparse-checkout sparse-checkout init --cone && > + git -C sparse-checkout sparse-checkout set folder1/0 folder3 && > + > + # test tab completion > + ( > + cd sparse-checkout && > + test_completion "git sparse-checkout set f" <<-\EOF > + folder1 Z > + folder1/0 Z > + folder1/0/1 Z > + folder2 Z > + folder2/0 Z > + folder3 Z This tab-completion doing a full directory walk seems like it could be expensive for a large repository, but I suppose it is the only way to allow the following sequence: fol<tab> -> folder folder1/<tab> -> folder1/0 folder1/0/<tab> -> folder1/0/1 (Hopefully that makes sense.) It would be more efficient to only go one level deep at a time, but that might not be possible with the tab completion mechanisms. > + EOF > + ) && > + > + ( > + cd sparse-checkout/folder1 && > + test_completion "git sparse-checkout add " <<-\EOF > + ./ Z > + 0 Z > + 0/1 Z > + EOF I do like seeing this test within a directory. Thanks! -Stolee