Skip to content

Commit cf3269f

Browse files
committed
Merge branch 'nd/init-relative-template-fix'
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
2 parents 86d2271 + e1df7fe commit cf3269f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

builtin/init-db.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
502502
if (real_git_dir && !is_absolute_path(real_git_dir))
503503
real_git_dir = real_pathdup(real_git_dir, 1);
504504

505+
if (template_dir && *template_dir && !is_absolute_path(template_dir))
506+
template_dir = absolute_pathdup(template_dir);
507+
505508
if (argc == 1) {
506509
int mkdir_tried = 0;
507510
retry:

t/t0001-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ test_expect_success 'reinit' '
175175
test_expect_success 'init with --template' '
176176
mkdir template-source &&
177177
echo content >template-source/file &&
178-
git init --template=../template-source template-custom &&
178+
git init --template=template-source template-custom &&
179179
test_cmp template-source/file template-custom/.git/file
180180
'
181181

t/t1301-shared-repo.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ test_expect_success POSIXPERM 'forced modes' '
136136
(
137137
cd new &&
138138
umask 002 &&
139-
git init --shared=0660 --template=../templates &&
139+
git init --shared=0660 --template=templates &&
140140
>frotz &&
141141
git add frotz &&
142142
git commit -a -m initial &&
@@ -192,7 +192,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'
192192
umask 0022 &&
193193
git init --bare --shared=0666 child.git &&
194194
test_path_is_missing child.git/foo &&
195-
git init --bare --template=../templates child.git &&
195+
git init --bare --template=templates child.git &&
196196
echo "-rw-rw-rw-" >expect &&
197197
test_modebits child.git/foo >actual &&
198198
test_cmp expect actual
@@ -203,7 +203,7 @@ test_expect_success POSIXPERM 'template can set core.sharedrepository' '
203203
umask 0022 &&
204204
git config core.sharedrepository 0666 &&
205205
cp .git/config templates/config &&
206-
git init --bare --template=../templates child.git &&
206+
git init --bare --template=templates child.git &&
207207
echo "-rw-rw-rw-" >expect &&
208208
test_modebits child.git/HEAD >actual &&
209209
test_cmp expect actual

0 commit comments

Comments
 (0)