Subject: Re: [PATCH] difftool: gracefully handle symlinks to directories

From: David Aguilar <[email-masked]>
Date: Tue, 27 Oct 2015 14:30:56 -0700

On Thu, Oct 22, 2015 at 11:23:54AM -0700, Junio C Hamano wrote:
> David Aguilar <[email-masked]> 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