From: David Aguilar Date: Tue, 27 Oct 2015 21:30:56 GMT Subject: Re: [PATCH] difftool: gracefully handle symlinks to directories Message-ID: <20151027213056.GA6527@gmail.com> In-Reply-To: On Thu, Oct 22, 2015 at 11:23:54AM -0700, Junio C Hamano wrote: > David Aguilar writes: > > > difftool's dir-diff feature was blindly feeding worktree paths > > to hash-object without checking whether the path was indeed a > > file, causing the feature to fail when repositories contain > > symlinks to directories. > > Wait. Anything that considers symlinks "to directories" any special > smells like a misdesign here. Why is it safe to substitute a > symbolic link that happens to point at a file with the file it > points at? > > Because the way you would hash a symblic link is not by hashing the > file it points at, but by hashing the result of readlink(2) of it, > we must not reuse the working tree files for any symbolic link, > regardless of its target, I would think. > > After all, a symbolic link may even be dangling and not pointing at > anything. Ah, right. I think the simplest thing to do is to tighten use_wt_file() so that it always rejects symlinks. That seems like a safe way to go for now without needing to invent a new paradigm for how to handle symlinks in the dir-diff code. I just sent a follow-up patch that does just that. Let me know if you'd like a replacement patch that combines the two patches instead. Thanks for the review, -- David