Web lists-archives.com

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

Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> 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.

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