Skip to content

Commit beab415

Browse files
committed
git-gui: remove EOL translation for gets
git-gui configures '-translation lf' on a number of channels. The default configuration is 'auto', which on input changes any occurrence of \n, \r, or \r\n to \n, and on output changes any such EOL sequence to a platform dependent value (\n on Unix, \r\n on Windows). Such translation can be necessary, but much of what is configured now is redundant. In particular, many of the channels configured this way are then consumed by gets, which already recognizes any of \n, \r, or \r\n as terminators. Configuring a channel to first change these line endings, then give the result to gets, is redundant. The valid uses of -translation lf are for output where we do not want \r\n on Windows, and for consuming entire files without going through gets, assuring that \n will be used internally. Let's remove all the others that only serve to confuse. lib/diff.tcl must have -translation lf because \r\n might be stored in the repository (e.g., on Windows, with no crlf translation enabled), and git will treat \n as the line ending, while the preceding \r is just whitespace, and these may be split by ANSI color coding. git-gui's read_diff handles this correctly as-is. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 07714e2 commit beab415

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

lib/blame.tcl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ method _load {jump} {
492492
}
493493
fconfigure $fd \
494494
-blocking 0 \
495-
-translation lf \
496495
-encoding [get_path_encoding $path]
497496
fileevent $fd readable [cb _read_file $fd $jump]
498497
set current_fd $fd
@@ -619,7 +618,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
619618

620619
lappend options -- $path
621620
set fd [git_read_nice [concat blame $options]]
622-
fconfigure $fd -blocking 0 -translation lf -encoding utf-8
621+
fconfigure $fd -blocking 0 -encoding utf-8
623622
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
624623
set current_fd $fd
625624
set blame_lines 0
@@ -985,7 +984,7 @@ method _showcommit {cur_w lno} {
985984
set msg {}
986985
catch {
987986
set fd [git_read [list cat-file commit $cmit]]
988-
fconfigure $fd -encoding iso8859-1 -translation lf
987+
fconfigure $fd -encoding iso8859-1
989988
# By default commits are assumed to be in utf-8
990989
set enc utf-8
991990
while {[gets $fd line] > 0} {

lib/choose_rev.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ constructor _new {path unmerged_only title} {
147147
refs/remotes \
148148
refs/tags \
149149
]]
150-
fconfigure $fr_fd -translation lf -encoding utf-8
150+
fconfigure $fr_fd -encoding utf-8
151151
while {[gets $fr_fd line] > 0} {
152152
set line [eval $line]
153153
if {[lindex $line 1 0] eq {tag}} {

lib/commit.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
2828
set name ""
2929
set email ""
3030
set fd [git_read [list cat-file commit $curHEAD]]
31-
fconfigure $fd -encoding iso8859-1 -translation lf
31+
fconfigure $fd -encoding iso8859-1
3232
# By default commits are assumed to be in utf-8
3333
set enc utf-8
3434
while {[gets $fd line] > 0} {
@@ -361,7 +361,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
361361
#
362362
if {$commit_type eq {normal}} {
363363
set fd_ot [git_read [list cat-file commit $PARENT]]
364-
fconfigure $fd_ot -encoding iso8859-1 -translation lf
364+
fconfigure $fd_ot -encoding iso8859-1
365365
set old_tree [gets $fd_ot]
366366
close $fd_ot
367367

lib/diff.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ proc start_show_diff {cont_info {add_opts {}}} {
324324
# '++' lines which is not bijective. Thus, we need to maintain a state
325325
# across lines.
326326
set ::conflict_in_pre_image 0
327+
328+
# git-diff has eol==\n, \r if present is part of the text
327329
fconfigure $fd \
328330
-blocking 0 \
329331
-encoding [get_path_encoding $path] \

lib/remote_branch_delete.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ method _load {cache uri} {
307307
set active_ls [git_read [list ls-remote $uri]]
308308
fconfigure $active_ls \
309309
-blocking 0 \
310-
-translation lf \
311310
-encoding utf-8
312311
fileevent $active_ls readable [cb _read $cache $active_ls]
313312
} else {

0 commit comments

Comments
 (0)