aboutsummaryrefslogtreecommitdiff
path: root/lib/encoding.tcl
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2008-09-18 01:07:34 +0400
committerShawn O. Pearce <spearce@spearce.org>2008-09-24 12:48:32 -0700
commit3fe0162362f80262ed1965f19c1f57f298931c94 (patch)
treedab7c45bb8241268d946bb281d30f4384cbf7b46 /lib/encoding.tcl
parent50102c5687db83db48b9705e07de16d07cef7cd9 (diff)
downloadgit-3fe0162362f80262ed1965f19c1f57f298931c94.tar.gz
git-3fe0162362f80262ed1965f19c1f57f298931c94.tar.xz
git-gui: Allow forcing display encoding for diffs using a submenu.
Add a submenu to allow dynamically changing the encoding to use for diffs. Encoding settings are remembered while git-gui runs. The rules are: 1) Encoding set for a specific file overrides gitattributes. 2) Last explicitly set value of the encoding overrides gui.encoding Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Tested-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib/encoding.tcl')
-rw-r--r--lib/encoding.tcl29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/encoding.tcl b/lib/encoding.tcl
index 2c1eda33e..b2ee38cc8 100644
--- a/lib/encoding.tcl
+++ b/lib/encoding.tcl
@@ -321,13 +321,38 @@ proc tcl_encoding {enc} {
return {}
}
+proc force_path_encoding {path enc} {
+ global path_encoding_overrides last_encoding_override
+
+ set enc [tcl_encoding $enc]
+ if {$enc eq {}} {
+ catch { unset last_encoding_override }
+ catch { unset path_encoding_overrides($path) }
+ } else {
+ set last_encoding_override $enc
+ if {$path ne {}} {
+ set path_encoding_overrides($path) $enc
+ }
+ }
+}
+
proc get_path_encoding {path} {
- set tcl_enc [tcl_encoding [get_config gui.encoding]]
+ global path_encoding_overrides last_encoding_override
+
+ if {[info exists last_encoding_override]} {
+ set tcl_enc $last_encoding_override
+ } else {
+ set tcl_enc [tcl_encoding [get_config gui.encoding]]
+ }
if {$tcl_enc eq {}} {
set tcl_enc [encoding system]
}
if {$path ne {}} {
- set enc2 [tcl_encoding [gitattr $path encoding $tcl_enc]]
+ if {[info exists path_encoding_overrides($path)]} {
+ set enc2 $path_encoding_overrides($path)
+ } else {
+ set enc2 [tcl_encoding [gitattr $path encoding $tcl_enc]]
+ }
if {$enc2 ne {}} {
set tcl_enc $enc2
}