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

Re: [PATCH] init: make --template path relative to $CWD

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2019, 06:12 UTC
Message-ID
<xmqq5zqedgrc.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190510104657.26585-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> During git-init we chdir() to the target directory, but --template is
> not adjusted. So it's relative to the target directory instead of
> current directory.
Show 8 quoted lines
> It would be ok if it's documented, but --template in git-init.txt
> mentions nothing about this behavior. Change it to be relative to $CWD,
> which is much more intuitive.
>
> The changes in the test suite show that this relative-to-target behavior
> is actually used. I just hope that it's only used in the test suite and
> it's safe to change. Otherwise, the other option is just document
> it (i.e. relative to target dir) and move on.
Yeah, that other option does sound safer, but ...
>  	mkdir template-source &&
>  	echo content >template-source/file &&
> -	git init --template=../template-source template-custom &&
> +	git init --template=template-source template-custom &&

... the example may show that the updated behaviour may match the end-user expectation better. It certainly is more in line with how the "--reference" option of "git clone" uses a relative path.

It also makes it easier to <TAB> complete if these things were relative to the current directory at the time of command invocation. I often find it frustrating when I have to create a symbolic link in a directory I am not yet in that points to somewhere using a relative path for the exact reason ;-)

Previous: Nguyễn Thái Ngọc Duy
Message 2 of 2 in “init: make --template path relative to $CWD”
  1. init: make --template path relative to $CWDNguyễn Thái Ngọc Duy, May 10, 2019
  2. Junio C HamanoMay 13, 2019

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.