Skip to content

Commit d92f844

Browse files
committed
Merge branch 'maint'
* maint: handle "git --bare init <dir>" properly
2 parents 73d4195 + 87a074d commit d92f844

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

builtin/init-db.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
463463
static char git_dir[PATH_MAX+1];
464464

465465
setenv(GIT_DIR_ENVIRONMENT,
466-
getcwd(git_dir, sizeof(git_dir)), 0);
466+
getcwd(git_dir, sizeof(git_dir)), argc > 0);
467467
}
468468

469469
if (init_shared_repository != -1)

t/t0001-init.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,18 @@ test_expect_success POSIXPERM 'init notices EPERM' '
310310
)
311311
'
312312

313+
test_expect_success 'init creates a new bare directory with global --bare' '
314+
rm -rf newdir &&
315+
git --bare init newdir &&
316+
test -d newdir/refs
317+
'
318+
319+
test_expect_success 'init prefers command line to GIT_DIR' '
320+
rm -rf newdir &&
321+
mkdir otherdir &&
322+
GIT_DIR=otherdir git --bare init newdir &&
323+
test -d newdir/refs &&
324+
! test -d otherdir/refs
325+
'
326+
313327
test_done

0 commit comments

Comments
 (0)