77
88gc_prog_name=" fmt-diff"
99
10- g_config=
11- g_local_rc=
12-
1310g_cached_opt=
1411
1512gf_debug=0
@@ -98,35 +95,12 @@ warn () (
9895
9996# git config --get {{{1
10097
101- # shellcheck disable=SC2142,SC2154
102- alias _git_conf_get__prep_conf_file_arg_=' conf="$1"; [ -n "$conf" ] && conf="--file \"$conf\""; shift'
103-
104- git_conf_get__call_ () (
105- getter=" $1 "
106- shift
107-
108- val=
109-
110- if [ -n " $g_local_rc " ]; then
111- val=" $( $getter " $g_local_rc " " $@ " ) "
112- fi
113-
114- if [ -z " $val " ]; then
115- val=" $( $getter " $g_config " " $@ " ) "
116- fi
117-
118- echo " $val "
119- )
120-
121- _git_conf_get__cb__ft_map () (
122- _git_conf_get__prep_conf_file_arg_
123-
98+ _git_conf_get__ft_map () (
12499 file=" $1 "
125100
126101 debug " args =" " $@ "
127102
128- # shellcheck disable=SC2086,SC2154
129- git config $conf --get-regexp " $gc_prog_name " ' \.map-' | while read -r line; do
103+ git config --get-regexp " $gc_prog_name " ' \.map-' | while read -r line; do
130104 debug " line = $line "
131105 line=" $( echo " $line " | awk -F' --' ' {print $2}' ) "
132106 ft=" $( echo " $line " | cut -d' ' -f1) "
@@ -142,17 +116,14 @@ _git_conf_get__cb__ft_map () (
142116 done
143117)
144118
145- _git_conf_get__cb__section_glob () (
146- _git_conf_get__prep_conf_file_arg_
147-
119+ _git_conf_get__glob__var () (
148120 debug " args =" " $@ "
149121
150122 file=" $1 "
151123 var=" $2 "
152124
153125 val=
154126
155- # shellcheck disable=SC2086
156127 while read -r line; do
157128 debug " line = $line "
158129 opt=" $( echo " $line " | cut -d' ' -f1) "
@@ -161,40 +132,32 @@ _git_conf_get__cb__section_glob () (
161132 $opt ) val=" $( echo " $line " | cut -d' ' -f2-) " ;;
162133 esac
163134 done << EOF
164- $( git config $conf --get-regexp " $gc_prog_name " ' \.[^=].*\.' " $var " ' $' )
135+ $( git config --get-regexp " $gc_prog_name " ' \.[^=].*\.' " $var " ' $' )
165136EOF
166137
167138 echo " $val "
168139)
169140
170- _git_conf_get__cb__simple () (
171- _git_conf_get__prep_conf_file_arg_
172- debug " args =" " $@ "
173- # shellcheck disable=SC2086
174- git config $conf --get " $@ "
175- )
176-
177-
178- git_conf_get__ft_formatter () (
141+ _git_conf_get__ft_formatter () (
179142 file=" $1 "
180143 ft=" $2 "
181144
182145 debug " args =" " $@ "
183146
184- fmt=" $( git_conf_get__call_ _git_conf_get__cb__section_glob " $file " " formatter-$ft " ) "
147+ fmt=" $( _git_conf_get__glob__var " $file " " formatter-$ft " ) "
185148
186149 if [ -z " $fmt " ]; then
187- fmt=" $( git_conf_get__call_ _git_conf_get__cb__simple " $gc_prog_name .=$ft .formatter" ) "
150+ fmt=" $( _git_conf_get__var " $gc_prog_name .=$ft .formatter" ) "
188151 fi
189152
190153 if [ -z " $fmt " ]; then
191- fmt=" $( git_conf_get__call_ _git_conf_get__cb__simple " $gc_prog_name .formatter-$ft " ) "
154+ fmt=" $( _git_conf_get__var " $gc_prog_name .formatter-$ft " ) "
192155 fi
193156
194157 echo " $fmt "
195158)
196159
197- git_conf_get__pager () (
160+ _git_conf_get__pager () (
198161 if [ " $gf_no_term " = 1 ]; then
199162 echo " cat"
200163 return
@@ -211,23 +174,28 @@ git_conf_get__pager () (
211174 echo " $pgr "
212175)
213176
177+ _git_conf_get__var () (
178+ debug " args =" " $@ "
179+ # shellcheck disable=SC2086
180+ git config $conf --get " $@ "
181+ )
214182
215183git_conf_get () (
216184 if [ " $1 " = " pager" ]; then
217- git_conf_get__pager
185+ _git_conf_get__pager
218186 return
219187 elif [ -z " $2 " ]; then
220- git_conf_get__call_ _git_conf_get__cb__simple " $1 "
188+ _git_conf_get__var " $1 "
221189 return
222190 fi
223191
224192 file=" $1 "
225193 var=" $2 "
226194
227- val=$( git_conf_get__call_ _git_conf_get__cb__section_glob " $file " " $var " )
195+ val=$( _git_conf_get__glob__var " $file " " $var " )
228196
229197 if [ -z " $val " ] && [ " $var " = " filetype" ]; then
230- val=" $( git_conf_get__call_ _git_conf_get__cb__ft_map " $file " ) "
198+ val=" $( _git_conf_get__ft_map " $file " ) "
231199 [ -z " $val " ] && return 1
232200 fi
233201
@@ -237,21 +205,21 @@ git_conf_get () (
237205 debug " var = $var "
238206 case " $var " in
239207 formatter)
240- val=" $( git_conf_get__ft_formatter " $file " " $ft " ) "
208+ val=" $( _git_conf_get__ft_formatter " $file " " $ft " ) "
241209 ;;
242210 * )
243- val=" $( git_conf_get__call_ _git_conf_get__cb__simple " $gc_prog_name .=$ft .$var " ) "
211+ val=" $( _git_conf_get__var " $gc_prog_name .=$ft .$var " ) "
244212 ;;
245213 esac
246214 fi
247215 fi
248216
249217 if [ -z " $val " ] && [ " $var " = " formatter" ]; then
250- val=" $( git_conf_get__call_ _git_conf_get__cb__simple " $gc_prog_name " ." $var " ) "
218+ val=" $( _git_conf_get__var " $gc_prog_name " ." $var " ) "
251219 fi
252220
253221 if [ -z " $val " ] && [ " $var " = " ignore" ]; then
254- list=" $( git_conf_get__call_ _git_conf_get__cb__simple " $gc_prog_name " ." $var " ) "
222+ list=" $( _git_conf_get__var " $gc_prog_name " ." $var " ) "
255223 if [ -n " $list " ]; then
256224 list=" $( echo " $list " | pat_list_to_case) "
257225 # shellcheck disable=SC2254
@@ -514,7 +482,6 @@ options:
514482 --staged a synonym of --cached
515483 --color always show colors
516484 --no-color turn off colored diff
517- --config <file> read config from specified file rather than \$ GIT_DIR/.git-$gc_prog_name
518485 --warn-risky-stderr redirects warning about potential unsolicited changes in suggestions to stderr;
519486 option not recommended as the warning blocks dangerous 'git apply'
520487EOU
@@ -536,14 +503,6 @@ while :; do
536503 --debug=* )
537504 gf_debug=" ${1# --debug=} "
538505 ;;
539- --config)
540- g_config=" $2 "
541- if [ -z " $g_config " ]; then
542- warn " option 'config' requires a path to config file as argument"
543- exit 1
544- fi
545- shift
546- ;;
547506 --color)
548507 gf_use_color=1
549508 ;;
@@ -585,11 +544,6 @@ done
585544[ -z " $gf_use_color " ] && gf_use_color=0
586545
587546repo_root=" $( git rev-parse --show-toplevel 2> /dev/null) "
588- if [ -z " $g_config " ] && [ -n " $repo_root " ]; then
589- if [ -e " $repo_root /.git-$gc_prog_name " ]; then
590- g_local_rc=" $repo_root /.git-$gc_prog_name "
591- fi
592- fi
593547
594548# setup env {{{2
595549TMPDIR=" ${TMPDIR:-/ tmp} " /git-" $gc_prog_name "
0 commit comments