On Mon, Jul 11, 2011 at 10:01 PM, Richard Heck <rgh...@comcast.net> wrote:
>     (i) "cd .." takes me to /home/rgheck/, as expected

I understand that the bash builtin cd command reinterpreting ".." to
mean slice off part of the path.

>     (ii) "ls .." gives me the files in /home/rgheck/files/, as not expected.

I understand this is the standard POSIX interpretation of ..; .. is a
hardlink to the parent directory that is created when the directory is
first created.

More discussion is at:
http://stackoverflow.com/questions/2105572/unix-softlinks-and-paths

> It looks like git acts like ls. If you have a symlink in a git repo, then
> the symlink is in the repo, but the stuff in the directory to which it
> points is not (unless that directory is in the repo anyway).
>
> So this means that we can figure out if we are in a repo by looking up the
> tree (apparently, stopping at the mount point, too, if I'm reading things
> correctly). But we have to follow the REAL parent, not just strip off path
> elements. I do not know how to do that, myself.

This is easy; pretty much everything follows the real parent, except
for shell builtins that try to be smart.

There is a "mountpoint" utility to find mountpoints. We could paste
some code in from mountpoint.c (attached). It seems to be a matter of
using lstat to find the device number, and probably also checking if
we've hit the root directory.

-- 
John C. McCabe-Dansted

Reply via email to