Skip to content

Commit

Permalink
Merge branch 'nd/init-relative-template-fix' into maint
Browse files Browse the repository at this point in the history
A relative pathname given to "git init --template=<path> <repo>"
ought to be relative to the directory "git init" gets invoked in,
but it instead was made relative to the repository, which has been
corrected.

* nd/init-relative-template-fix:
  init: make --template path relative to $CWD
  • Loading branch information
gitster committed Jul 25, 2019
2 parents b697d92 + e1df7fe commit 35d7715
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions builtin/init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
if (real_git_dir && !is_absolute_path(real_git_dir))
real_git_dir = real_pathdup(real_git_dir, 1);

if (template_dir && *template_dir && !is_absolute_path(template_dir))
template_dir = absolute_pathdup(template_dir);

if (argc == 1) {
int mkdir_tried = 0;
retry:
Expand Down
2 changes: 1 addition & 1 deletion t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ test_expect_success 'reinit' '
test_expect_success 'init with --template' '
mkdir template-source &&
echo content >template-source/file &&
git init --template=../template-source template-custom &&
git init --template=template-source template-custom &&
test_cmp template-source/file template-custom/.git/file
'

Expand Down
6 changes: 3 additions & 3 deletions t/t1301-shared-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ test_expect_success POSIXPERM 'forced modes' '
(
cd new &&
umask 002 &&
git init --shared=0660 --template=../templates &&
git init --shared=0660 --template=templates &&
>frotz &&
git add frotz &&
git commit -a -m initial &&
Expand Down Expand Up @@ -192,7 +192,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'
umask 0022 &&
git init --bare --shared=0666 child.git &&
test_path_is_missing child.git/foo &&
git init --bare --template=../templates child.git &&
git init --bare --template=templates child.git &&
echo "-rw-rw-rw-" >expect &&
test_modebits child.git/foo >actual &&
test_cmp expect actual
Expand All @@ -203,7 +203,7 @@ test_expect_success POSIXPERM 'template can set core.sharedrepository' '
umask 0022 &&
git config core.sharedrepository 0666 &&
cp .git/config templates/config &&
git init --bare --template=../templates child.git &&
git init --bare --template=templates child.git &&
echo "-rw-rw-rw-" >expect &&
test_modebits child.git/HEAD >actual &&
test_cmp expect actual
Expand Down

0 comments on commit 35d7715

Please sign in to comment.