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

Re: [PATCH] fix misuse of prefix_path()

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Feb 4, 2008, 11:13 UTC
Message-ID
<1202123606.47a6f3567ebb9@webmail.eunet.at>
In-Reply-To
<7v3as9mce7.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> When DEFAULT_GIT_TEMPLATE_DIR is specified as a relative path,
> init-db made it relative to exec_path using prefix_path(), which
> is wrong.  prefix_path() is about a file inside the work tree.
> There was a similar misuse in config.c that takes relative
> ETC_GITCONFIG path.
>
> A convenience function prefix_filename() can concatenate two paths
> to form a path that points at somewhere outside the work tree.
> Use it in these codepaths instead.

Thanks for catching that. But, no, your patch does not work. The reason is that prefix_filename() assumes that the prefix ends with a directory separator ('/'), but git_exec_path() doesn't have one.

prefix_path() has the same assumption, but at the same time it does the "../" sanitization. In the MinGW configuration both relative paths begin with "../" and prefix_path() removed one path component from the prefix, but left a trailing '/' behind. IOW, so far the code worked by accident, not by design ;)

I'll work on a fix (later today).
-- Hannes
Previous: Johannes SchindelinNext: Johannes Sixt
Message 4 of 6 in “fix misuse of prefix_path()”
  1. fix misuse of prefix_path()Junio C Hamano, Feb 4, 2008
  2. builtin-mv: minimum fix to avoid losing filesJunio C Hamano, Feb 4, 2008
  3. Johannes SchindelinFeb 4, 2008
  4. Johannes SixtFeb 4, 2008
  5. Fix misuse of prefix_path()Johannes Sixt, Feb 5, 2008
  6. Junio C HamanoFeb 5, 2008

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.