@@ -2534,40 +2534,79 @@ test_expect_success 'options with value' '
2534
2534
'
2535
2535
2536
2536
test_expect_success ' sourcing the completion script clears cached commands' '
2537
- __git_compute_all_commands &&
2538
- verbose test -n "$__git_all_commands" &&
2539
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2540
- verbose test -z "$__git_all_commands"
2537
+ (
2538
+ __git_compute_all_commands &&
2539
+ verbose test -n "$__git_all_commands" &&
2540
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2541
+ verbose test -z "$__git_all_commands"
2542
+ )
2541
2543
'
2542
2544
2543
2545
test_expect_success ' sourcing the completion script clears cached merge strategies' '
2544
- __git_compute_merge_strategies &&
2545
- verbose test -n "$__git_merge_strategies" &&
2546
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2547
- verbose test -z "$__git_merge_strategies"
2546
+ (
2547
+ __git_compute_merge_strategies &&
2548
+ verbose test -n "$__git_merge_strategies" &&
2549
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2550
+ verbose test -z "$__git_merge_strategies"
2551
+ )
2548
2552
'
2549
2553
2550
2554
test_expect_success ' sourcing the completion script clears cached --options' '
2551
- __gitcomp_builtin checkout &&
2552
- verbose test -n "$__gitcomp_builtin_checkout" &&
2553
- __gitcomp_builtin notes_edit &&
2554
- verbose test -n "$__gitcomp_builtin_notes_edit" &&
2555
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2556
- verbose test -z "$__gitcomp_builtin_checkout" &&
2557
- verbose test -z "$__gitcomp_builtin_notes_edit"
2555
+ (
2556
+ __gitcomp_builtin checkout &&
2557
+ verbose test -n "$__gitcomp_builtin_checkout" &&
2558
+ __gitcomp_builtin notes_edit &&
2559
+ verbose test -n "$__gitcomp_builtin_notes_edit" &&
2560
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2561
+ verbose test -z "$__gitcomp_builtin_checkout" &&
2562
+ verbose test -z "$__gitcomp_builtin_notes_edit"
2563
+ )
2558
2564
'
2559
2565
2560
2566
test_expect_success ' option aliases are not shown by default' '
2561
2567
test_completion "git clone --recurs" "--recurse-submodules "
2562
2568
'
2563
2569
2564
2570
test_expect_success ' option aliases are shown with GIT_COMPLETION_SHOW_ALL' '
2565
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2566
- GIT_COMPLETION_SHOW_ALL=1 && export GIT_COMPLETION_SHOW_ALL &&
2567
- test_completion "git clone --recurs" <<-\EOF
2568
- --recurse-submodules Z
2569
- --recursive Z
2570
- EOF
2571
+ (
2572
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2573
+ GIT_COMPLETION_SHOW_ALL=1 && export GIT_COMPLETION_SHOW_ALL &&
2574
+ test_completion "git clone --recurs" <<-\EOF
2575
+ --recurse-submodules Z
2576
+ --recursive Z
2577
+ EOF
2578
+ )
2579
+ '
2580
+
2581
+ test_expect_success ' plumbing commands are excluded without GIT_COMPLETION_SHOW_ALL_COMMANDS' '
2582
+ (
2583
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2584
+ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
2585
+
2586
+ # Just mainporcelain, not plumbing commands
2587
+ run_completion "git c" &&
2588
+ grep checkout out &&
2589
+ ! grep cat-file out
2590
+ )
2591
+ '
2592
+
2593
+ test_expect_success ' all commands are shown with GIT_COMPLETION_SHOW_ALL_COMMANDS (also main non-builtin)' '
2594
+ (
2595
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
2596
+ GIT_COMPLETION_SHOW_ALL_COMMANDS=1 &&
2597
+ export GIT_COMPLETION_SHOW_ALL_COMMANDS &&
2598
+ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
2599
+
2600
+ # Both mainporcelain and plumbing commands
2601
+ run_completion "git c" &&
2602
+ grep checkout out &&
2603
+ grep cat-file out &&
2604
+
2605
+ # Check "gitk", a "main" command, but not a built-in + more plumbing
2606
+ run_completion "git g" &&
2607
+ grep gitk out &&
2608
+ grep get-tar-commit-id out
2609
+ )
2571
2610
'
2572
2611
2573
2612
test_expect_success ' __git_complete' '
0 commit comments