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

Re: [PATCH 1/5] Add is_absolute_path(), make_absolute_path() and normalize_path()

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 26, 2007, 19:02 UTC
Message-ID
<Pine.LNX.4.64.0707261955540.14781@racer.site>
In-Reply-To
<7v4pjr80lr.fsf@assigned-by-dhcp.cox.net>
Hi,
On Thu, 26 Jul 2007, Junio C Hamano wrote:
Show 17 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Agree.  Maybe a comment above the function, like
> >
> > 	/*
> > 	 * The function normalize_path() converts ".." and "." names in 
> > 	 * the given path so that "foo/../bar/./" will come out as "bar".
> > 	 *
> > 	 * Note: normalize_path() does not follow symlinks, so if "foo" is
> > 	 * a symlink in the example above, the result will not work as 
> > 	 * expected.
> > 	 */
> >
> > Hmm?
> 
> That comment only states the obvious and does not give a clue to
> the callers when it should not be used, I am afraid.

I am afraid, that it was unobvious enough to yours truly to forget about that when writing the patch.

Show 8 quoted lines
> For example, paths taken out of index or recursively reading trees are 
> Ok because there will not be ".." and "." in them.  Making a path given 
> by the user relative to the cwd by prepending what is returned by 
> setup_git_directory() may or may not be safe, depending on how 
> setup_git_directory() does things (I think the original one is safe; I 
> am reasonably sure with the current one when GIT_WORK_TREE is not in 
> use; I do not know when that environment variable is there with the 
> current code with or without your patch series).

I am afraid that already GIT_DIR can contain symlinks, and is not checked by setup_git_env().

So I think some concrete comment is needed in _addition_:
	get_git_dir() is not safe, and therefore git_path(), too.
Hmm.

Maybe the easiest way _is_ to getcwd(); chdir() getcwd(); chdir(back); Ugly.

Ciao, Dscho

Previous: Junio C Hamano
Message 5 of 5 in “Add is_absolute_path(), make_absolute_path() and normalize_path()”
  1. 1/5 Add is_absolute_path(), make_absolute_path() and normalize_path()Johannes Schindelin, Jul 26, 2007
  2. Junio C HamanoJul 26, 2007
  3. Johannes SchindelinJul 26, 2007
  4. Junio C HamanoJul 26, 2007
  5. Johannes SchindelinJul 26, 2007

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.