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

Re: git grep doesn't follow symbolic link

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Jan 15, 2012, 09:47 UTC
Message-ID
<CACsJy8CaBAEJo_LuvjYhb2kfofH83cbR5DFDffmmCU3uJFqk+g@mail.gmail.com>
In-Reply-To
<7v1ur1yazf.fsf@alter.siamese.dyndns.org>
On Sun, Jan 15, 2012 at 9:07 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Stop and think what "git diff --follow-symlinks v1.3.0 v1.7.0" should do
> when these versions record a symbolic link, "from user perspective", if
> the link points outside the tracked contents. Naturally, the users would
> expect that the comparison is made between the contents of the file back
> when v1.3.0 was tagged and the contents of the file (which may or may not
> be the same path depending on the target of that symbolic link) back when
> v1.7.0 was tagged.
>
> But that is something that the user is *NOT* tracking with the system, and
> hence something we cannot give the right answer. Your "--follow-symlinks"
> option only encourages the *wrong* perception on the users' side, without
> supporting what it appears to promise to the users. Why could it be an
> improvement?

It's not wrong per se. It's an implication that users have to take when they choose to use it. We may help make it clear that the symlinks point to untracked files by putting some indication in the diff.

When I do "git log -Sfoo -- '*.cxx'" I don't really care if bar.cxx is a symlink. Neither does my compiler. It may be a symlink's target change that makes "foo" appear. Git could help me detect that quickly instead of sticking with tracked contents only.

Even if we decide --follow-symlinks=untracked is a bad idea, --follow-symlinks=tracked (i.e. follow symlinks to tracked files only) is still a good thing to support. And I suspect that's a more common case as linking outside repository could is undeterministic.

The "=tracked" could be dropped if we have no other option value. I'm thinking of --follow-symlinks=submodule, which is currently covered by a separate option name.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “git grep doesn't follow symbolic link”
  1. Bertrand BENOITJan 9, 2012
  2. Ramkumar RamachandraJan 10, 2012
  3. Thomas RastJan 10, 2012
  4. Junio C HamanoJan 10, 2012
  5. Nguyen Thai Ngoc DuyJan 14, 2012
  6. Junio C HamanoJan 15, 2012
  7. Nguyen Thai Ngoc DuyJan 15, 2012
  8. Junio C HamanoJan 16, 2012
  9. Nguyen Thai Ngoc DuyJan 17, 2012
  10. Junio C HamanoJan 17, 2012

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.