@@ -2660,6 +2660,31 @@ __git_compute_config_vars ()
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,73 +2829,50 @@ __git_complete_config_variable_name ()
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\n autoSetupRebase\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
* .* )
0 commit comments