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

Re: Git doesn't support symlinks

From
Danh Doan <congdanhqx@gmail.com>
Date
Mar 26, 2020, 00:50 UTC
Message-ID
<20200326005037.GA5398@danh.dev>
In-Reply-To
<F9453040-2E7D-4CAB-AA7F-0C6C04E2FC99@googlemail.com>
On 2020-03-25 20:37:30-0400, Daniel Malendez <dmalendez@googlemail.com> wrote:
Show 26 quoted lines
> Thanks for your feedback!
> 
> > On Mar 25, 2020, at 8:23 PM, Bryan Turner <bturner@atlassian.com> wrote:
> > 
> > This didn't add the same thing. What does a "git status" show at this
> > point? I'd expect it would show "Versions/Current/Headers/interior.h"
> > as added to the index, not "Headers/interior.h".
> 
> $ git add .
> $ git status
> Changes to be committed:
>   (use "git rm --cached <file>..." to unstage)
> 	new file:   Foo.framework/Headers
> 	new file:   Foo.framework/Versions/A/Headers/Interior.h
> 
> > It doesn't necessarily seem like a bug, to me; more like a case where
> > Git could potentially be "smarter" to try and determine that, while
> > "Headers/interior.h" is beyond a symlink, the target of that symlink
> > is still in the repository. (Versions/Current _is_ in the same
> > repository, right?)
> 
> Agree, makes sense!
> 
> I think what happens here is that `git add .` adds the
> Foo.framework/Headers directory first, to circumvent this check
> failing here?

"Foo.framework/Headers" is a symlinks, and git simply adds that, without caring where it's linked to.

To git, there's nothing inside "Foo.framework/Headers", it's a blob, which happends to be type: symlink.

IOW, you can:
	$ git add Foo.framework/Headers # without add the target
	$ ln -s /usr/bin bin
	$ git add bin # git won't write to index anything from /usr/bin
> https://github.com/git/git/blob/master/pathspec.c#L596
> Whereas a single “git add path/to/file” would fail here
-- 
Danh
Previous: Daniel Malendez
Message 4 of 4 in “Git doesn't support symlinks”
  1. Daniel MalendezMar 25, 2020
  2. Bryan TurnerMar 26, 2020
  3. Daniel MalendezMar 26, 2020
  4. Danh DoanMar 26, 2020

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.