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

Re: Proposed function path_in_directory()

From
Johannes Sixt <j6t@kdbg.org>
Date
Oct 8, 2012, 18:20 UTC
Message-ID
<50731968.7020602@kdbg.org>
In-Reply-To
<7vy5jhlz70.fsf@alter.siamese.dyndns.org>
Am 08.10.2012 18:13, schrieb Junio C Hamano:
Show 7 quoted lines
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>> 2. Does there need to be any special related to DOS paths?
> 
> The ceiling computation may need special case for dos.  What does
> the getcwd() give us?  Do we learn only the path within the "current
> drive" and need to prefix C: (or D: or X:) ourselves if we really
> want to tell C:\bin and D:\bin apart?
We don't have to do that. getcwd() returns the drive letter.
Show 11 quoted lines
> Assuming that is the case, the ceiling computation would need a
> helper function that hides the gory details of prefixing getcwd()
> result with drive letter or whatever needed, and another that
> normalizes the elements of the environment variables (I presume that
> if an element in it without the drive prefix should be normalized to
> add the current drive letter to it so that the normalized getcwd()
> result can be compared with it).  E.g. if the ceiling list is
> "D:/a/b;/trash/" then getcwd() returning "/a" alone does not make it
> outside the ceiling due to "D:/a/b"---our current drive must be "D"
> for that pattern to kick in.  The unqualified /trash would apply to
> any drive.

A component in an path list like GIT_CEILING_DIRECTORIES or PATH that does not contain the drive letter is a user error. Do not cater for it.

It is more important to take into account that those components can contain backslash as directory separators, while our mingw_getcwd() returns forward slashes.

-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 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.