@matheusbsbs / matheus-bagliano / commits / 2d19f8e921
Fork 0

git-gui: show unstaged symlinks in diff viewer

git-gui has a minor problem with regards to symlinks that point to directories. git init mkdir realdir ln -s realdir linkdir git gui Now clicking on file names in the "unstaged changes" window, there's a problem coming from the "linkdir" symlink: git-gui complains with error reading "file4": illegal operation on a directory ...even though git-gui can add that same symlink to the index just fine. This patch fix this by adding a check. [sp: Minor fix to use {link} instead of "link" in condition and to only open the path if it is not a symlink.] Signed-off-by: Michele Ballabio <barra_cuda@katamail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Michele Ballabio committed Sep 9, 2007 at 21:04 UTC 2d19f8e921a1cdc562783814747819b0d5a12641
1 file changed +10 -5
lib/diff.tcl
+10 -5
@@ -85,11 +85,16 @@ proc show_diff {path w {lno {}}} {
85 if {$m eq {_O}} {
86 set max_sz [expr {128 * 1024}]
87 if {[catch {
88 - set fd [open $path r]
89 - fconfigure $fd -eofchar {}
90 - set content [read $fd $max_sz]
91 - close $fd
92 - set sz [file size $path]
88 + if {[file type $path] == {link}} {
89 + set content [file readlink $path]
90 + set sz [string length $content]
91 + } else {
92 + set fd [open $path r]
93 + fconfigure $fd -eofchar {}
94 + set content [read $fd $max_sz]
95 + close $fd
96 + set sz [file size $path]
97 + }
98 } err ]} {
99 set diff_active 0
100 unlock_index