]> asedeno.scripts.mit.edu Git - git.git/commitdiff
git-gui: Correct bugs in font config handling.
authorShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 20:45:35 +0000 (15:45 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 13 Nov 2006 05:10:37 +0000 (00:10 -0500)
Apparently Tcl is being helpful on Windows during exec and is throwing a
\ in front of every { it finds in the string.  I'm guessing they think
the value might be read by another Tcl program?  Anyway, Git faithfully
stores the \{ sequence and sends it back that way to Tcl, at which point
Tcl parses the list wrong and starts to break it in the middle of any
element which contains spaces.  Therefore a list such as:

  -family {Times New Roman}

gets broken up into the pairs:

  {-family \{Times}
  {New Roman}

which is very incorrect.  So now we replace all { and } with "", at which
point Tcl doesn't throw \ in front of the " on the way out to Git yet it
reads it correctly as a list on the way back in.

I also found and fixed a bug in the way we restored the fonts when the
user presses Restore Defaults in the options dialog.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui

diff --git a/git-gui b/git-gui
index 2138d2d2e19ba0ddbfdac4727dde006eff8b0d3e..e59d225cb6c50febe1707404e7fbd7eb3069a18a 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -91,7 +91,8 @@ proc save_config {} {
                        if {$value == $default_config($name)} {
                                catch {exec git repo-config --global --unset $name}
                        } else {
-                               catch {exec git repo-config --global $name $value}
+                               regsub -all "\[{}\]" $value {"} value
+                               exec git repo-config --global $name $value
                        }
                        set global_config($name) $value
                        if {$value == $repo_config($name)} {
@@ -107,7 +108,8 @@ proc save_config {} {
                        if {$value == $global_config($name)} {
                                catch {exec git repo-config --unset $name}
                        } else {
-                               catch {exec git repo-config $name $value}
+                               regsub -all "\[{}\]" $value {"} value
+                               exec git repo-config $name $value
                        }
                        set repo_config($name) $value
                }
@@ -1803,7 +1805,7 @@ proc do_options {} {
 }
 
 proc do_restore_defaults {} {
-       global font_descs default_config
+       global font_descs default_config repo_config
        global repo_config_new global_config_new
 
        foreach name [array names default_config] {
@@ -1813,7 +1815,7 @@ proc do_restore_defaults {} {
 
        foreach option $font_descs {
                set name [lindex $option 0]
-               set repo_config($name) $default_config(gui.$name)
+               set repo_config(gui.$name) $default_config(gui.$name)
        }
        apply_config