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 ;-)