summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/init-db.c2
-rwxr-xr-xt/t0001-init.sh14
2 files changed, 15 insertions, 1 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index edc40ff..0271285 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -463,7 +463,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
static char git_dir[PATH_MAX+1];
setenv(GIT_DIR_ENVIRONMENT,
- getcwd(git_dir, sizeof(git_dir)), 0);
+ getcwd(git_dir, sizeof(git_dir)), argc > 0);
}
if (init_shared_repository != -1)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 6757734..7c0a698 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -310,4 +310,18 @@ test_expect_success POSIXPERM 'init notices EPERM' '
)
'
+test_expect_success 'init creates a new bare directory with global --bare' '
+ rm -rf newdir &&
+ git --bare init newdir &&
+ test -d newdir/refs
+'
+
+test_expect_success 'init prefers command line to GIT_DIR' '
+ rm -rf newdir &&
+ mkdir otherdir &&
+ GIT_DIR=otherdir git --bare init newdir &&
+ test -d newdir/refs &&
+ ! test -d otherdir/refs
+'
+
test_done