diff options
| author | Alexander Gavrilov <angavrilov@gmail.com> | 2008-09-18 01:07:32 +0400 | 
|---|---|---|
| committer | Shawn O. Pearce <spearce@spearce.org> | 2008-09-24 12:48:32 -0700 | 
| commit | 72e6b002021e45255f568fc0c885d82de75ae935 (patch) | |
| tree | fb76f3bbe6e8006a6aca0ee59d6a2f1b51247904 /lib/encoding.tcl | |
| parent | 696235c6c1c85085fd55ff849663d44c51464e69 (diff) | |
| download | git-72e6b002021e45255f568fc0c885d82de75ae935.tar.gz | |
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.tcl | 14 | 
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 +} | 
