Skip to content

Commit 153ad78

Browse files
angavrilovspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent d1f2b36 commit 153ad78

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

git-gui.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,19 +940,25 @@ git-version proc _parse_config {arr_name args} {
940940
}
941941
942942
proc load_config {include_global} {
943-
global repo_config global_config default_config
943+
global repo_config global_config system_config default_config
944944
945945
if {$include_global} {
946+
_parse_config system_config --system
946947
_parse_config global_config --global
947948
}
948949
_parse_config repo_config
949950
950951
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] {
951957
if {[catch {set v $global_config($name)}]} {
952-
set global_config($name) $default_config($name)
958+
set global_config($name) $system_config($name)
953959
}
954960
if {[catch {set v $repo_config($name)}]} {
955-
set repo_config($name) $default_config($name)
961+
set repo_config($name) $system_config($name)
956962
}
957963
}
958964
}

lib/option.tcl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ proc config_check_encodings {} {
2525

2626
proc save_config {} {
2727
global default_config font_descs
28-
global repo_config global_config
28+
global repo_config global_config system_config
2929
global repo_config_new global_config_new
3030
global ui_comm_spell
3131

@@ -49,7 +49,7 @@ proc save_config {} {
4949
foreach name [array names default_config] {
5050
set value $global_config_new($name)
5151
if {$value ne $global_config($name)} {
52-
if {$value eq $default_config($name)} {
52+
if {$value eq $system_config($name)} {
5353
catch {git config --global --unset $name}
5454
} else {
5555
regsub -all "\[{}\]" $value {"} value
@@ -284,17 +284,17 @@ proc do_options {} {
284284
}
285285

286286
proc do_restore_defaults {} {
287-
global font_descs default_config repo_config
287+
global font_descs default_config repo_config system_config
288288
global repo_config_new global_config_new
289289

290290
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)
293293
}
294294

295295
foreach option $font_descs {
296296
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)
298298
}
299299
apply_config
300300

0 commit comments

Comments
 (0)