summaryrefslogtreecommitdiff
path: root/lib/encoding.tcl
diff options
context:
space:
mode:
authorLibravatar Alexander Gavrilov <angavrilov@gmail.com>2008-09-18 01:07:32 +0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2008-09-24 12:48:32 -0700
commit72e6b002021e45255f568fc0c885d82de75ae935 (patch)
treefb76f3bbe6e8006a6aca0ee59d6a2f1b51247904 /lib/encoding.tcl
parentgit-gui: Assume `blame --incremental` output is in UTF-8 (diff)
downloadtgif-72e6b002021e45255f568fc0c885d82de75ae935.tar.xz
git-gui: Cleanup handling of the default encoding.
- Make diffs and blame default to the system (locale) encoding instead of hard-coding UTF-8. - Add a gui.encoding option to allow overriding it. - gitattributes still have the final word. The rationale for this is Windows support: 1) Windows people are accustomed to using legacy encodings for text files. For many of them defaulting to utf-8 will be counter-intuitive. 2) Windows doesn't support utf-8 locales, and switching the system encoding is a real pain. Thus the option. This patch also adds proper encoding conversion to Apply Hunk/Line. 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.tcl14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/encoding.tcl b/lib/encoding.tcl
index 7f06b0d47f..e186b0c569 100644
--- a/lib/encoding.tcl
+++ b/lib/encoding.tcl
@@ -274,3 +274,17 @@ proc tcl_encoding {enc} {
}
return {}
}
+
+proc get_path_encoding {path} {
+ 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 {$enc2 ne {}} {
+ set tcl_enc $enc2
+ }
+ }
+ return $tcl_enc
+}