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>
Shawn O. Pearce committed
Oct 12, 2007 at 00:42 UTC
f00d504a6fcf29944311a497d0eb76f0fe5ef8f0
1 file changed
+14
-21
git-gui.sh
+14
-21
@@ -748,40 +748,33 @@ unset -nocomplain idx fd
748
##
749
## config file parsing
750
751
-proc load_config {include_global} {
752
- global repo_config global_config default_config
753
-
754
- array unset global_config
755
- if {$include_global} {
751
+git-version proc _parse_config {arr_name args} {
752
+ default {
753
+ upvar $arr_name arr
754
+ array unset arr
755
catch {
757
- set fd_rc [git_read config --global --list]
756
+ set fd_rc [eval [list git_read config --list] $args]
757
while {[gets $fd_rc line] >= 0} {
758
if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
759
if {[is_many_config $name]} {
761
- lappend global_config($name) $value
760
+ lappend arr($name) $value
761
} else {
763
- set global_config($name) $value
762
+ set arr($name) $value
763
}
764
}
765
}
766
close $fd_rc
767
}
768
}
769
+}
770
771
- array unset repo_config
772
- catch {
773
- set fd_rc [git_read config --list]
774
- while {[gets $fd_rc line] >= 0} {
775
- if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
776
- if {[is_many_config $name]} {
777
- lappend repo_config($name) $value
778
- } else {
779
- set repo_config($name) $value
780
- }
781
- }
782
- }
783
- close $fd_rc
771
+proc load_config {include_global} {
772
+ global repo_config global_config default_config
773
+
774
+ if {$include_global} {
775
+ _parse_config global_config --global
776
}
777
+ _parse_config repo_config
778
779
foreach name [array names default_config] {
780
if {[catch {set v $global_config($name)}]} {