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