git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
David Aguilar <davvid@gmail.com>
Date
Oct 27, 2015, 21:30 UTC
Message-ID
<20151027213056.GA6527@gmail.com>
In-Reply-To
<xmqq8u6usqx1.fsf@gitster.mtv.corp.google.com>
On Thu, Oct 22, 2015 at 11:23:54AM -0700, Junio C Hamano wrote:
Show 19 quoted lines
> David Aguilar <davvid@gmail.com> 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
Previous: Junio C Hamano
Message 3 of 3 in “difftool: gracefully handle symlinks to directories”
  1. difftool: gracefully handle symlinks to directoriesDavid Aguilar, Oct 21, 2015
  2. Junio C HamanoOct 22, 2015
  3. David AguilarOct 27, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.