summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-01-25 02:30:23 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-01-25 05:25:32 (GMT)
commit30b14ed390f543e52665c8fc4f626aab78e3dcab (patch)
treee94be76467c04397bd5a4575d8ea9f17bded0d0a
parenta25c51893317bcbd8e8a85b6da3a573fcd096d86 (diff)
downloadgit-30b14ed390f543e52665c8fc4f626aab78e3dcab.zip
git-30b14ed390f543e52665c8fc4f626aab78e3dcab.tar.gz
git-30b14ed390f543e52665c8fc4f626aab78e3dcab.tar.bz2
git-gui: Elide CRs appearing in diff output from display.
If we are displaying a diff for a DOS-style (CRLF) formatted file then the Tk text widget would normally show the CR at the end of every line; in most fonts this will come out as a square box. Rather than showing this character we'll tag it with a tag which forces the character to be elided away, so its not displayed. However since the character is still within the text buffer we can still obtain it and supply it over to `git apply` when staging or unstaging an individual hunk, ensuring that the file contents is always fully preserved as-is. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/git-gui.sh b/git-gui.sh
index c8098ac..ee7fdaa 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -793,6 +793,9 @@ proc read_diff {fd} {
}
}
$ui_diff insert end $line $tags
+ if {[string index $line end] eq "\r"} {
+ $ui_diff tag add d_cr {end - 2c}
+ }
$ui_diff insert end "\n" $tags
}
$ui_diff conf -state disabled
@@ -4304,6 +4307,7 @@ pack $ui_diff -side left -fill both -expand 1
pack .vpane.lower.diff.header -side top -fill x
pack .vpane.lower.diff.body -side bottom -fill both -expand 1
+$ui_diff tag conf d_cr -elide true
$ui_diff tag conf d_@ -foreground blue -font font_diffbold
$ui_diff tag conf d_+ -foreground {#00a000}
$ui_diff tag conf d_- -foreground red