git-gui: When possible show the type of an untracked file.
Users may want to know what a file is before they add it to the repository, especially if its a binary file. So when possible invoke 'file' on the path and try to get its output. Since this is strictly advice to the user we won't bother to report any failures from our attempt to run `file`. Since some file commands also output the path name they were given we look for that case and strip it off the front of the returned output before placing it into the diff viewer. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 23, 2007 at 03:18 UTC
d3596fd9486b602252d5b2c3e14ac55a07a2bdb9
1 file changed
+8
git-gui.sh
+8
@@ -640,6 +640,14 @@ proc show_diff {path w {lno {}}} {
640
return
641
}
642
$ui_diff conf -state normal
643
+ if {![catch {set type [exec file $path]}]} {
644
+ set n [string length $path]
645
+ if {[string equal -length $n $path $type]} {
646
+ set type [string range $type $n end]
647
+ regsub {^:?\s*} $type {} type
648
+ }
649
+ $ui_diff insert end "* $type\n" d_@
650
+ }
651
if {[string first "\0" $content] != -1} {
652
$ui_diff insert end \
653
"* Binary file (not showing content)." \