[PATCH] git-gui: a minor fix in procedure show_diff{}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Michele Ballabio <barra_cuda@xxxxxxxxxxxx>
---

Another (similar) minor problem can be seen with:

	git init
	mkdir git_dir
	cd git_dir
	git init
	echo file > file
	git add file
	git commit -a -m "commit"
	cd ..
	git-gui

I.e. directories containing a git repo show up in git-gui as
empty, triggering the error shown above.

I don't know the right fix for this, though. I suspect git-submodule
should be involved.

 lib/diff.tcl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/diff.tcl b/lib/diff.tcl
index b1129d5..08b0e6f 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -87,7 +87,11 @@ proc show_diff {path w {lno {}}} {
 		if {[catch {
 				set fd [open $path r]
 				fconfigure $fd -eofchar {}
-				set content [read $fd $max_sz]
+				if {[file type $path] == "link"} {
+					set content [file readlink $path]
+				} else {
+					set content [read $fd $max_sz]
+				}
 				close $fd
 				set sz [file size $path]
 			} err ]} {
-- 
1.5.3

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux