Skip to content

Commit

Permalink
git-gui: show unstaged symlinks in diff viewer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michele Ballabio authored and Shawn O. Pearce committed Sep 9, 2007
1 parent c63fe3b commit 2d19f8e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/diff.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ proc show_diff {path w {lno {}}} {
if {$m eq {_O}} {
set max_sz [expr {128 * 1024}]
if {[catch {
set fd [open $path r]
fconfigure $fd -eofchar {}
set content [read $fd $max_sz]
close $fd
set sz [file size $path]
if {[file type $path] == {link}} {
set content [file readlink $path]
set sz [string length $content]
} else {
set fd [open $path r]
fconfigure $fd -eofchar {}
set content [read $fd $max_sz]
close $fd
set sz [file size $path]
}
} err ]} {
set diff_active 0
unlock_index
Expand Down

0 comments on commit 2d19f8e

Please sign in to comment.