git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 1, 2012, 05:30 UTC
Message-ID
<7vipauep32.fsf@alter.siamese.dyndns.org>
In-Reply-To
<50692150.8080504@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 11 quoted lines
> 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.

Previous: Michael HaggertyNext: Michael Haggerty
Message 12 of 17 in “Fix GIT_CEILING_DIRECTORIES that contain symlinks”
  1. 0/9 Fix GIT_CEILING_DIRECTORIES that contain symlinksMichael Haggerty, Sep 29, 2012
  2. 1/9 Introduce new static function real_path_internal()Michael Haggerty, Sep 29, 2012
  3. 2/9 real_path_internal(): add comment explaining use of cwdMichael Haggerty, Sep 29, 2012
  4. 3/9 Introduce new function real_path_if_valid()Michael Haggerty, Sep 29, 2012
  5. 4/9 longest_ancestor_length(): use string_list_split()Michael Haggerty, Sep 29, 2012
  6. 5/9 longest_ancestor_length(): explicitly filter list before loopMichael Haggerty, Sep 29, 2012
  7. 6/9 longest_ancestor_length(): always add a slash to the end of prefixesMichael Haggerty, Sep 29, 2012
  8. 7/9 longest_ancestor_length(): use string_list_longest_prefix()Michael Haggerty, Sep 29, 2012
  9. 8/9 longest_ancestor_length(): resolve symlinks before comparing pathsMichael Haggerty, Sep 29, 2012
  10. Junio C HamanoSep 30, 2012
  11. Michael HaggertyOct 1, 2012
  12. Junio C HamanoOct 1, 2012
  13. Proposed function path_in_directory() [was: Re: [PATCH v2 8/9] longest_ancestor_length(): resolve symlinks before comparing paths]Michael Haggerty, Oct 6, 2012
  14. Junio C HamanoOct 8, 2012
  15. Johannes SixtOct 8, 2012
  16. Junio C HamanoOct 8, 2012
  17. 9/9 t1504: stop resolving symlinks in GIT_CEILING_DIRECTORIESMichael Haggerty, Sep 29, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.