@@ -803,6 +803,50 @@ __git_find_on_cmdline ()
803803 done
804804}
805805
806+ # Echo the value of an option set on the command line or config
807+ #
808+ # $1: short option name
809+ # $2: long option name including =
810+ # $3: list of possible values
811+ # $4: config string (optional)
812+ #
813+ # example:
814+ # result="$(__git_get_option_value "-d" "--do-something=" \
815+ # "yes no" "core.doSomething")"
816+ #
817+ # result is then either empty (no option set) or "yes" or "no"
818+ #
819+ # __git_get_option_value requires 3 arguments
820+ __git_get_option_value ()
821+ {
822+ local c short_opt long_opt val
823+ local result= values config_key word
824+
825+ short_opt=" $1 "
826+ long_opt=" $2 "
827+ values=" $3 "
828+ config_key=" $4 "
829+
830+ (( c = $cword - 1 ))
831+ while [ $c -ge 0 ]; do
832+ word=" ${words[c]} "
833+ for val in $values ; do
834+ if [ " $short_opt$val " = " $word " ] ||
835+ [ " $long_opt$val " = " $word " ]; then
836+ result=" $val "
837+ break 2
838+ fi
839+ done
840+ (( c-- ))
841+ done
842+
843+ if [ -n " $config_key " ] && [ -z " $result " ]; then
844+ result=" $( git --git-dir=" $( __gitdir) " config " $config_key " ) "
845+ fi
846+
847+ echo " $result "
848+ }
849+
806850__git_has_doubledash ()
807851{
808852 local c=1
@@ -1098,6 +1142,8 @@ _git_clone ()
10981142 esac
10991143}
11001144
1145+ __git_untracked_file_modes=" all no normal"
1146+
11011147_git_commit ()
11021148{
11031149 case " $prev " in
@@ -1119,7 +1165,7 @@ _git_commit ()
11191165 return
11201166 ;;
11211167 --untracked-files=* )
1122- __gitcomp " all no normal " " " " ${cur## --untracked-files=} "
1168+ __gitcomp " $__git_untracked_file_modes " " " " ${cur## --untracked-files=} "
11231169 return
11241170 ;;
11251171 --* )
@@ -1780,6 +1826,56 @@ _git_stage ()
17801826 _git_add
17811827}
17821828
1829+ _git_status ()
1830+ {
1831+ local complete_opt
1832+ local untracked_state
1833+
1834+ case " $cur " in
1835+ --ignore-submodules=* )
1836+ __gitcomp " none untracked dirty all" " " " ${cur## --ignore-submodules=} "
1837+ return
1838+ ;;
1839+ --untracked-files=* )
1840+ __gitcomp " $__git_untracked_file_modes " " " " ${cur## --untracked-files=} "
1841+ return
1842+ ;;
1843+ --column=* )
1844+ __gitcomp "
1845+ always never auto column row plain dense nodense
1846+ " " " " ${cur## --column=} "
1847+ return
1848+ ;;
1849+ --* )
1850+ __gitcomp "
1851+ --short --branch --porcelain --long --verbose
1852+ --untracked-files= --ignore-submodules= --ignored
1853+ --column= --no-column
1854+ "
1855+ return
1856+ ;;
1857+ esac
1858+
1859+ untracked_state=" $( __git_get_option_value " -u" " --untracked-files=" \
1860+ " $__git_untracked_file_modes " " status.showUntrackedFiles" ) "
1861+
1862+ case " $untracked_state " in
1863+ no)
1864+ # --ignored option does not matter
1865+ complete_opt=
1866+ ;;
1867+ all|normal|* )
1868+ complete_opt=" --cached --directory --no-empty-directory --others"
1869+
1870+ if [ -n " $( __git_find_on_cmdline " --ignored" ) " ]; then
1871+ complete_opt=" $complete_opt --ignored --exclude=*"
1872+ fi
1873+ ;;
1874+ esac
1875+
1876+ __git_complete_index_file " $complete_opt "
1877+ }
1878+
17831879__git_config_get_set_variables ()
17841880{
17851881 local prevword word config_file= c=$cword
0 commit comments