From 464c9ffee45520c8be3ec656f926224501bcf977 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 23 Jan 2007 02:08:09 -0500 Subject: [PATCH] git-gui: Don't show content of untracked binary files. A binary file can be very large, and showing the complete content of one is horribly ugly and confusing. So we now use the same rule that core Git uses; if there is a NUL byte (\0) within the first 8000 bytes of the file we assume it is binary and refuse to show the content. Given that we have loaded the entire content of the file into memory we probably could just afford to search the whole thing, but we also probably should not load multi-megabyte binary files either. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 6ccd4113d..9136e7fe9 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -637,6 +637,9 @@ proc show_diff {path w {lno {}}} { error_popup "Error loading file:\n\n$err" return } + if {[string first "\0" [string range $content 0 8000]] != -1} { + set content {* Binary file (not showing content).} + } $ui_diff conf -state normal $ui_diff insert end $content $ui_diff conf -state disabled -- 2.26.2