git-gui: Implement system-wide configuration handling.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sun, 16 Nov 2008 18:46:47 +0000 (21:46 +0300)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 16 Nov 2008 21:33:09 +0000 (13:33 -0800)
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>
git-gui.sh
lib/option.tcl
index 6ed6230d3c1431df4d91973e6cc3bd846f2f9b7e..f849e745ba742a081b6934652f4cbf1885162d9c 100755 (executable)
@@ -940,19 +940,25 @@ git-version proc _parse_config {arr_name args} {
 }
 
 proc load_config {include_global} {
-       global repo_config global_config default_config
+       global repo_config global_config system_config default_config
 
        if {$include_global} {
+               _parse_config system_config --system
                _parse_config global_config --global
        }
        _parse_config repo_config
 
        foreach name [array names default_config] {
+               if {[catch {set v $system_config($name)}]} {
+                       set system_config($name) $default_config($name)
+               }
+       }
+       foreach name [array names system_config] {
                if {[catch {set v $global_config($name)}]} {
-                       set global_config($name) $default_config($name)
+                       set global_config($name) $system_config($name)
                }
                if {[catch {set v $repo_config($name)}]} {
-                       set repo_config($name) $default_config($name)
+                       set repo_config($name) $system_config($name)
                }
        }
 }
index c80c9398786baa63a5023b3e0123a228d148ce34..1d55b49c9bd8182cad2066ecdb81630ca6ad24a6 100644 (file)
@@ -25,7 +25,7 @@ proc config_check_encodings {} {
 
 proc save_config {} {
        global default_config font_descs
-       global repo_config global_config
+       global repo_config global_config system_config
        global repo_config_new global_config_new
        global ui_comm_spell
 
@@ -49,7 +49,7 @@ proc save_config {} {
        foreach name [array names default_config] {
                set value $global_config_new($name)
                if {$value ne $global_config($name)} {
-                       if {$value eq $default_config($name)} {
+                       if {$value eq $system_config($name)} {
                                catch {git config --global --unset $name}
                        } else {
                                regsub -all "\[{}\]" $value {"} value
@@ -284,17 +284,17 @@ proc do_options {} {
 }
 
 proc do_restore_defaults {} {
-       global font_descs default_config repo_config
+       global font_descs default_config repo_config system_config
        global repo_config_new global_config_new
 
        foreach name [array names default_config] {
-               set repo_config_new($name) $default_config($name)
-               set global_config_new($name) $default_config($name)
+               set repo_config_new($name) $system_config($name)
+               set global_config_new($name) $system_config($name)
        }
 
        foreach option $font_descs {
                set name [lindex $option 0]
-               set repo_config(gui.$name) $default_config(gui.$name)
+               set repo_config(gui.$name) $system_config(gui.$name)
        }
        apply_config