Subject: Acceptability of replacing .git internals with symlinks

From: "brian m. carlson" <[email-masked]>
Date: Thu, 24 Apr 2025 22:32:31 +0000

Git LFS has gotten a couple of bug reports[0][1] about it failing when
some of the innards of the `.git` directory are replaced with symlinks.
This happens because the Android `repo` tool creates repositories this
way; why that is, I don't know.

I know _part_ of the problem for Git LFS is due to the fact that some
operations are run under, say, `.git/objects`, and if that's a symlink
then the path canonicalization puts the directory elsewhere and the
`.git` directory detection fails.  I don't know if that's all of the
problem, or just part of it.

My inquiry here is whether we consider it acceptable for tools to create
symlinks from Git internals in this way and whether this is a thing that
should be fixed or not.  I haven't tested with alternate Git
implementations, such as JGit, Game of Trees, dulwich, libgit2, or
others, so I don't know how gracefully they handle this.  I will assume
for the sake of discussion that the symlinks can be created successfully
without elevated permissions and the OS and file system are fully
functional in this regard.

I know symlinking the `hooks` directory is common and semi-suppported,
but I don't know how we feel about other directories, such as `objects`.

If we _do_ want to support this, then we should probably add some tests
for it, and if we don't, then we may want to add advice or diagnostics
to discourage this behaviour.

[0] https://github.com/git-lfs/git-lfs/issues/5426
[1] https://github.com/git-lfs/git-lfs/issues/603
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA