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