Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v2 8/9] longest_ancestor_length(): resolve symlinks before comparing paths

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:54

Michael Haggerty [off-list ref] writes:
I think I would advocate that the prefix has to match the front of
the path exactly (including any trailing slashes) and either

    strlen(prefix) == 0
    or the prefix ended with a '/'
    or the prefix and path are identical
    or the character in path following the matching part is a '/'

This would allow the "is path its own prefix" policy to be decided by
the caller by either including or omitting a trailing slash on the
prefix argument.
I think that is sensible thing to do.

The primary thing I found questionable was that the function, given
"/net/wink/project/frotz" to check against "/pub:/s" (or "/pub/:/s/"
if you like), will report that "/net/wink/project" directory is the
longest ancestor, when "/s" is a symlink that happens to point at
"/net/wink/project".  It is very counter-intuitive when you view its
two input strings as strings.  By making its sole caller expand the
symbolic links, it would be a lot clearer what is going on to
anybody who follow the codepath.  We have one path obtained from
getcwd() and a set of paths all of which are real paths without
symbolic aliasing, and we check if one among the latter cover
an earlier part of the former.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help