@matheusbsbs / matheus-bagliano / commits / 153ad78b50
Fork 0

git-gui: Implement system-wide configuration handling.

With the old implementation any system-wide options appear to be set locally in the current repository. This commit adds explicit handling of system options, essentially interpreting them as customized default_config. The difficulty in interpreting system options stems from the fact that simple 'git config' lists all values, while 'git config --global' only values set in ~/.gitconfig, excluding both local and system options. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Alexander Gavrilov committed Nov 16, 2008 at 21:46 UTC 153ad78b5074b37215654b1ccb59e67dc5831883
2 files changed +15 -9
git-gui.sh
+9 -3
@@ -940,19 +940,25 @@ git-version proc _parse_config {arr_name args} {
940 }
941
942 proc load_config {include_global} {
943 - global repo_config global_config default_config
943 + global repo_config global_config system_config default_config
944
945 if {$include_global} {
946 + _parse_config system_config --system
947 _parse_config global_config --global
948 }
949 _parse_config repo_config
950
951 foreach name [array names default_config] {
952 + if {[catch {set v $system_config($name)}]} {
953 + set system_config($name) $default_config($name)
954 + }
955 + }
956 + foreach name [array names system_config] {
957 if {[catch {set v $global_config($name)}]} {
952 - set global_config($name) $default_config($name)
958 + set global_config($name) $system_config($name)
959 }
960 if {[catch {set v $repo_config($name)}]} {
955 - set repo_config($name) $default_config($name)
961 + set repo_config($name) $system_config($name)
962 }
963 }
964 }
lib/option.tcl
+6 -6
@@ -25,7 +25,7 @@ proc config_check_encodings {} {
25
26 proc save_config {} {
27 global default_config font_descs
28 - global repo_config global_config
28 + global repo_config global_config system_config
29 global repo_config_new global_config_new
30 global ui_comm_spell
31
@@ -49,7 +49,7 @@ proc save_config {} {
49 foreach name [array names default_config] {
50 set value $global_config_new($name)
51 if {$value ne $global_config($name)} {
52 - if {$value eq $default_config($name)} {
52 + if {$value eq $system_config($name)} {
53 catch {git config --global --unset $name}
54 } else {
55 regsub -all "\[{}\]" $value {"} value
@@ -284,17 +284,17 @@ proc do_options {} {
284 }
285
286 proc do_restore_defaults {} {
287 - global font_descs default_config repo_config
287 + global font_descs default_config repo_config system_config
288 global repo_config_new global_config_new
289
290 foreach name [array names default_config] {
291 - set repo_config_new($name) $default_config($name)
292 - set global_config_new($name) $default_config($name)
291 + set repo_config_new($name) $system_config($name)
292 + set global_config_new($name) $system_config($name)
293 }
294
295 foreach option $font_descs {
296 set name [lindex $option 0]
297 - set repo_config(gui.$name) $default_config(gui.$name)
297 + set repo_config(gui.$name) $system_config(gui.$name)
298 }
299 apply_config
300