Re: gitignore as symbolic link

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 22, 2021 at 1:57 PM Rene Kita <mail@xxxxxxx> wrote:
>
> On Thu, Oct 21, 2021 at 05:07:44PM -0800, Justus Ranvier wrote:
> > I have several repositories where the top level .gitignore file is a
> > symbolic link to the actual file which is contained in a submodule which all
> > the repositories share.
> >
> > This worked fine up to and including version 2.31.1 but as of 2.32.0 running
> > any command which would cause .gitignore to be read results in a "too many
> > levels of symbolic links error" and git behaves as if .gitignore is not
> > present.
> >
> This was fixed in commit a185dd58ecc17f2ea16985d59c9bb7b09bec7775 [1].

Hmm, the behavior Justus described is actually related to another
change. Since v2.32.0, git no longer follows ".gitattributes",
".gitignore" and ".mailmap" if they are symbolic links. It does that
by open()-ing these files with the O_NOFOLLOW flag, which returns
ELOOP ("too many levels of symbolic links error") when the basename is
a symlink. So the behavior you experienced is actually not a bug, but
an intended change.

For a full explanation please see a2ef579e261 ("attr: do not respect
symlinks for in-tree .gitattributes", 2021-02-16) [2] and feb9b7792f
("exclude: do not respect symlinks for in-tree .gitignore",
2021-02-16) [3].

But the short version is: git accesses these files either from the
working tree or the object store (think, e.g. a bare repo). Git never
follows symlinks in the second case, so following them on the working
tree was an inconsistent behavior which was fixed. (This also has a
security implication, in the sense that it could be dangerous to
follow symlinks that lead to paths outside the repository.)

Note that "core.excludesFile" and "$GIT_DIR/info/exclude" are still
allowed to be symlinks.

[2]: https://github.com/git/git/commit/2ef579e261
[3]: https://github.com/git/git/commit/feb9b7792f

> [1] https://lore.kernel.org/git/xmqqlf83h2a7.fsf@gitster.g/



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux