Git fork

Merge branch 'pb/complete-config'

The command line completion script (in contrib/) learned to
complete configuration variable names better.

* pb/complete-config:
completion: add and use __git_compute_second_level_config_vars_for_section
completion: add and use __git_compute_first_level_config_vars_for_section
completion: complete 'submodule.*' config variables
completion: add space after config variable names also in Bash 3

+75 -44
+46 -44
contrib/completion/git-completion.bash
··· 2660 2660 __git_config_vars="$(git help --config-for-completion)" 2661 2661 } 2662 2662 2663 + __git_config_vars_all= 2664 + __git_compute_config_vars_all () 2665 + { 2666 + test -n "$__git_config_vars_all" || 2667 + __git_config_vars_all="$(git --no-pager help --config)" 2668 + } 2669 + 2670 + __git_compute_first_level_config_vars_for_section () 2671 + { 2672 + local section="$1" 2673 + __git_compute_config_vars 2674 + local this_section="__git_first_level_config_vars_for_section_${section}" 2675 + test -n "${!this_section}" || 2676 + printf -v "__git_first_level_config_vars_for_section_${section}" %s "$(echo "$__git_config_vars" | grep -E "^${section}\.[a-z]" | awk -F. '{print $2}')" 2677 + } 2678 + 2679 + __git_compute_second_level_config_vars_for_section () 2680 + { 2681 + local section="$1" 2682 + __git_compute_config_vars_all 2683 + local this_section="__git_second_level_config_vars_for_section_${section}" 2684 + test -n "${!this_section}" || 2685 + printf -v "__git_second_level_config_vars_for_section_${section}" %s "$(echo "$__git_config_vars_all" | grep -E "^${section}\.<" | awk -F. '{print $3}')" 2686 + } 2687 + 2663 2688 __git_config_sections= 2664 2689 __git_compute_config_sections () 2665 2690 { ··· 2804 2829 done 2805 2830 2806 2831 case "$cur_" in 2807 - branch.*.*) 2832 + branch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*) 2808 2833 local pfx="${cur_%.*}." 2809 2834 cur_="${cur_##*.}" 2810 - __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx" 2835 + local section="${pfx%.*.}" 2836 + __git_compute_second_level_config_vars_for_section "${section}" 2837 + local this_section="__git_second_level_config_vars_for_section_${section}" 2838 + __gitcomp "${!this_section}" "$pfx" "$cur_" "$sfx" 2811 2839 return 2812 2840 ;; 2813 2841 branch.*) 2814 2842 local pfx="${cur_%.*}." 2815 2843 cur_="${cur_#*.}" 2844 + local section="${pfx%.}" 2816 2845 __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" 2817 - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" 2818 - return 2819 - ;; 2820 - guitool.*.*) 2821 - local pfx="${cur_%.*}." 2822 - cur_="${cur_##*.}" 2823 - __gitcomp " 2824 - argPrompt cmd confirm needsFile noConsole noRescan 2825 - prompt revPrompt revUnmerged title 2826 - " "$pfx" "$cur_" "$sfx" 2827 - return 2828 - ;; 2829 - difftool.*.*) 2830 - local pfx="${cur_%.*}." 2831 - cur_="${cur_##*.}" 2832 - __gitcomp "cmd path" "$pfx" "$cur_" "$sfx" 2833 - return 2834 - ;; 2835 - man.*.*) 2836 - local pfx="${cur_%.*}." 2837 - cur_="${cur_##*.}" 2838 - __gitcomp "cmd path" "$pfx" "$cur_" "$sfx" 2839 - return 2840 - ;; 2841 - mergetool.*.*) 2842 - local pfx="${cur_%.*}." 2843 - cur_="${cur_##*.}" 2844 - __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx" 2846 + __git_compute_first_level_config_vars_for_section "${section}" 2847 + local this_section="__git_first_level_config_vars_for_section_${section}" 2848 + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" 2845 2849 return 2846 2850 ;; 2847 2851 pager.*) 2848 2852 local pfx="${cur_%.*}." 2849 2853 cur_="${cur_#*.}" 2850 2854 __git_compute_all_commands 2851 - __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }" 2852 - return 2853 - ;; 2854 - remote.*.*) 2855 - local pfx="${cur_%.*}." 2856 - cur_="${cur_##*.}" 2857 - __gitcomp " 2858 - url proxy fetch push mirror skipDefaultUpdate 2859 - receivepack uploadpack tagOpt pushurl 2860 - " "$pfx" "$cur_" "$sfx" 2855 + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }" 2861 2856 return 2862 2857 ;; 2863 2858 remote.*) 2864 2859 local pfx="${cur_%.*}." 2865 2860 cur_="${cur_#*.}" 2861 + local section="${pfx%.}" 2866 2862 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." 2867 - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }" 2863 + __git_compute_first_level_config_vars_for_section "${section}" 2864 + local this_section="__git_first_level_config_vars_for_section_${section}" 2865 + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" 2868 2866 return 2869 2867 ;; 2870 - url.*.*) 2868 + submodule.*) 2871 2869 local pfx="${cur_%.*}." 2872 - cur_="${cur_##*.}" 2873 - __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx" 2870 + cur_="${cur_#*.}" 2871 + local section="${pfx%.}" 2872 + __gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "." 2873 + __git_compute_first_level_config_vars_for_section "${section}" 2874 + local this_section="__git_first_level_config_vars_for_section_${section}" 2875 + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" 2874 2876 return 2875 2877 ;; 2876 2878 *.*)
+29
t/t9902-completion.sh
··· 2724 2724 EOF 2725 2725 ' 2726 2726 2727 + test_expect_success 'setup for git config submodule tests' ' 2728 + test_create_repo sub && 2729 + test_commit -C sub initial && 2730 + git submodule add ./sub 2731 + ' 2732 + 2733 + test_expect_success 'git config - variable name - submodule and __git_compute_first_level_config_vars_for_section' ' 2734 + test_completion "git config submodule." <<-\EOF 2735 + submodule.active Z 2736 + submodule.alternateErrorStrategy Z 2737 + submodule.alternateLocation Z 2738 + submodule.fetchJobs Z 2739 + submodule.propagateBranches Z 2740 + submodule.recurse Z 2741 + submodule.sub.Z 2742 + EOF 2743 + ' 2744 + 2745 + test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' ' 2746 + test_completion "git config submodule.sub." <<-\EOF 2747 + submodule.sub.url Z 2748 + submodule.sub.update Z 2749 + submodule.sub.branch Z 2750 + submodule.sub.fetchRecurseSubmodules Z 2751 + submodule.sub.ignore Z 2752 + submodule.sub.active Z 2753 + EOF 2754 + ' 2755 + 2727 2756 test_expect_success 'git config - value' ' 2728 2757 test_completion "git config color.pager " <<-\EOF 2729 2758 false Z