git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matheus Tavares <matheus.bernardino@usp.br>
To: Rene Kita <mail@rkta.de>
Cc: Justus Ranvier <justus@opentransactions.org>, git <git@vger.kernel.org>
Subject: Re: gitignore as symbolic link
Date: Fri, 22 Oct 2021 19:40:53 -0300	[thread overview]
Message-ID: <CAHd-oW50puNCrYTQhR4qffgtP6-wJerWLhmhCV+nYcLVNu+CBg@mail.gmail.com> (raw)
In-Reply-To: <YXLro/8c1Feg6TcN@kitchen>

On Fri, Oct 22, 2021 at 1:57 PM Rene Kita <mail@rkta.de> 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/

  reply	other threads:[~2021-10-22 22:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  1:07 gitignore as symbolic link Justus Ranvier
2021-10-22 16:49 ` Rene Kita
2021-10-22 22:40   ` Matheus Tavares [this message]
2021-10-22 23:29     ` Justus Ranvier
2021-10-22 23:55     ` Justus Ranvier
2021-10-23 12:01       ` brian m. carlson
2021-10-23 15:40         ` Justus Ranvier
2021-10-23 20:49           ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHd-oW50puNCrYTQhR4qffgtP6-wJerWLhmhCV+nYcLVNu+CBg@mail.gmail.com \
    --to=matheus.bernardino@usp.br \
    --cc=git@vger.kernel.org \
    --cc=justus@opentransactions.org \
    --cc=mail@rkta.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).