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/diff.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/diff.tcl')
| -rw-r--r-- | lib/diff.tcl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl index b0ecfbcb59..8fefc5d9ae 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -164,11 +164,10 @@ proc show_other_diff {path w m scroll_pos} { set sz [string length $content] } file { - set enc [gitattr $path encoding UTF-8] set fd [open $path r] fconfigure $fd \ -eofchar {} \ - -encoding [tcl_encoding $enc] + -encoding [get_path_encoding $path] set content [read $fd $max_sz] close $fd set sz [file size $path] @@ -282,7 +281,7 @@ proc start_show_diff {scroll_pos {add_opts {}}} { set ::current_diff_inheader 1 fconfigure $fd \ -blocking 0 \ - -encoding [tcl_encoding [gitattr $path encoding UTF-8]] \ + -encoding [get_path_encoding $path] \ -translation lf fileevent $fd readable [list read_diff $fd $scroll_pos] } @@ -435,8 +434,9 @@ proc apply_hunk {x y} { } if {[catch { + set enc [get_path_encoding $current_diff_path] set p [eval git_write $apply_cmd] - fconfigure $p -translation binary -encoding binary + fconfigure $p -translation binary -encoding $enc puts -nonewline $p $current_diff_header puts -nonewline $p [$ui_diff get $s_lno $e_lno] close $p} err]} { @@ -604,8 +604,9 @@ proc apply_line {x y} { set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch" if {[catch { + set enc [get_path_encoding $current_diff_path] set p [eval git_write $apply_cmd] - fconfigure $p -translation binary -encoding binary + fconfigure $p -translation binary -encoding $enc puts -nonewline $p $current_diff_header puts -nonewline $p $patch close $p} err]} { |
