git-gui: Refactor git-config --list parsing
The parsing for the output of `git config --list` is the same for both the global options and the current repository's options so we can really just use the same parser between them. I'm currently just refactoring the parser so we can use a different one depending on the version of git available to us at runtime. My next change will add support for 1.5.3's --null option. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
69f85ffaa2
commit
f00d504a6f
51
git-gui.sh
51
git-gui.sh
@ -748,40 +748,33 @@ unset -nocomplain idx fd
|
|||||||
##
|
##
|
||||||
## config file parsing
|
## config file parsing
|
||||||
|
|
||||||
|
git-version proc _parse_config {arr_name args} {
|
||||||
|
default {
|
||||||
|
upvar $arr_name arr
|
||||||
|
array unset arr
|
||||||
|
catch {
|
||||||
|
set fd_rc [eval [list git_read config --list] $args]
|
||||||
|
while {[gets $fd_rc line] >= 0} {
|
||||||
|
if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
|
||||||
|
if {[is_many_config $name]} {
|
||||||
|
lappend arr($name) $value
|
||||||
|
} else {
|
||||||
|
set arr($name) $value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close $fd_rc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proc load_config {include_global} {
|
proc load_config {include_global} {
|
||||||
global repo_config global_config default_config
|
global repo_config global_config default_config
|
||||||
|
|
||||||
array unset global_config
|
|
||||||
if {$include_global} {
|
if {$include_global} {
|
||||||
catch {
|
_parse_config global_config --global
|
||||||
set fd_rc [git_read config --global --list]
|
|
||||||
while {[gets $fd_rc line] >= 0} {
|
|
||||||
if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
|
|
||||||
if {[is_many_config $name]} {
|
|
||||||
lappend global_config($name) $value
|
|
||||||
} else {
|
|
||||||
set global_config($name) $value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close $fd_rc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
array unset repo_config
|
|
||||||
catch {
|
|
||||||
set fd_rc [git_read config --list]
|
|
||||||
while {[gets $fd_rc line] >= 0} {
|
|
||||||
if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
|
|
||||||
if {[is_many_config $name]} {
|
|
||||||
lappend repo_config($name) $value
|
|
||||||
} else {
|
|
||||||
set repo_config($name) $value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close $fd_rc
|
|
||||||
}
|
}
|
||||||
|
_parse_config repo_config
|
||||||
|
|
||||||
foreach name [array names default_config] {
|
foreach name [array names default_config] {
|
||||||
if {[catch {set v $global_config($name)}]} {
|
if {[catch {set v $global_config($name)}]} {
|
||||||
|
Loading…
Reference in New Issue
Block a user