Jeff King [off-list ref] writes:
quoted
mkdir settings
cd settings
git init
touch x
...
cd ..
git init
git add settings/
(should complain)
If you do "git add settings" (without the slash) it will add the
repository as a submodule. Which is not the behavior you asked for, but
is at least reasonable. So the real bug seems to me the fact that "git
add settings/" and "git add settings" behave differently.
Also if "git add settings/x" does not complain, that would be a bigger
issue, whose solution would probably be in the same area.
It may finally be the time to rename has_symlink_leading_path() function
and enhance its feature. It happens to check leading symlinks, but its
real purpose is to check if the given path is outside the working tree,
and a path that is in a subdirectory with its own .git repository
certainly is outside the working tree. The callers should be able to say
what check is being asked for by naming the _purpose_ of the test ("is
this path outside the working tree?"), not the mechanics ("does the path
have a symlink that points outside?").