aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Levedahl <mlevedahl@gmail.com>2025-05-21 21:13:27 -0400
committerMark Levedahl <mlevedahl@gmail.com>2025-07-31 13:50:59 -0400
commitbeab415e429067108953966d3d2d4420d75515cd (patch)
tree41fdd528dd5050d9d5e621c19445f90facd5e934
parentgit-gui: do not mix -translation binary and -encoding (diff)
downloadgit-beab415e429067108953966d3d2d4420d75515cd.tar.gz
git-beab415e429067108953966d3d2d4420d75515cd.zip
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 <mlevedahl@gmail.com>
-rw-r--r--lib/blame.tcl5
-rw-r--r--lib/choose_rev.tcl2
-rw-r--r--lib/commit.tcl4
-rw-r--r--lib/diff.tcl2
-rw-r--r--lib/remote_branch_delete.tcl1
5 files changed, 7 insertions, 7 deletions
diff --git a/lib/blame.tcl b/lib/blame.tcl
index bb67b047eb..22c5e7a193 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -492,7 +492,6 @@ method _load {jump} {
}
fconfigure $fd \
-blocking 0 \
- -translation lf \
-encoding [get_path_encoding $path]
fileevent $fd readable [cb _read_file $fd $jump]
set current_fd $fd
@@ -619,7 +618,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
lappend options -- $path
set fd [git_read_nice [concat blame $options]]
- fconfigure $fd -blocking 0 -translation lf -encoding utf-8
+ fconfigure $fd -blocking 0 -encoding utf-8
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
set current_fd $fd
set blame_lines 0
@@ -985,7 +984,7 @@ method _showcommit {cur_w lno} {
set msg {}
catch {
set fd [git_read [list cat-file commit $cmit]]
- fconfigure $fd -encoding iso8859-1 -translation lf
+ fconfigure $fd -encoding iso8859-1
# By default commits are assumed to be in utf-8
set enc utf-8
while {[gets $fd line] > 0} {
diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl
index 4cf6cebac4..cd355cc92a 100644
--- a/lib/choose_rev.tcl
+++ b/lib/choose_rev.tcl
@@ -147,7 +147,7 @@ constructor _new {path unmerged_only title} {
refs/remotes \
refs/tags \
]]
- fconfigure $fr_fd -translation lf -encoding utf-8
+ fconfigure $fr_fd -encoding utf-8
while {[gets $fr_fd line] > 0} {
set line [eval $line]
if {[lindex $line 1 0] eq {tag}} {
diff --git a/lib/commit.tcl b/lib/commit.tcl
index adde708084..5e77fd2f54 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -28,7 +28,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
set name ""
set email ""
set fd [git_read [list cat-file commit $curHEAD]]
- fconfigure $fd -encoding iso8859-1 -translation lf
+ fconfigure $fd -encoding iso8859-1
# By default commits are assumed to be in utf-8
set enc utf-8
while {[gets $fd line] > 0} {
@@ -361,7 +361,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
#
if {$commit_type eq {normal}} {
set fd_ot [git_read [list cat-file commit $PARENT]]
- fconfigure $fd_ot -encoding iso8859-1 -translation lf
+ fconfigure $fd_ot -encoding iso8859-1
set old_tree [gets $fd_ot]
close $fd_ot
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 65d0997b79..442737ba4f 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -324,6 +324,8 @@ proc start_show_diff {cont_info {add_opts {}}} {
# '++' lines which is not bijective. Thus, we need to maintain a state
# across lines.
set ::conflict_in_pre_image 0
+
+ # git-diff has eol==\n, \r if present is part of the text
fconfigure $fd \
-blocking 0 \
-encoding [get_path_encoding $path] \
diff --git a/lib/remote_branch_delete.tcl b/lib/remote_branch_delete.tcl
index 349d31edf3..f0814efdd7 100644
--- a/lib/remote_branch_delete.tcl
+++ b/lib/remote_branch_delete.tcl
@@ -307,7 +307,6 @@ method _load {cache uri} {
set active_ls [git_read [list ls-remote $uri]]
fconfigure $active_ls \
-blocking 0 \
- -translation lf \
-encoding utf-8
fileevent $active_ls readable [cb _read $cache $active_ls]
} else {