summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2010-05-10 05:42:06 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-05-10 11:25:37 -0700
commit87a074df2455f305df8facc22e85dac1cfeb0d6b (patch)
treeddc38543916d6dc2bc3f2e700278ca85365df2b1 /t
parentcherry-pick: do not dump core when iconv fails (diff)
downloadtgif-87a074df2455f305df8facc22e85dac1cfeb0d6b.tar.xz
handle "git --bare init <dir>" properly
If we know we are creating a bare repository, we use setenv to set the GIT_DIR directory to the current directory (either where we already were, or one we created and chdir'd into with "git init --bare <dir>"). However, with "git --bare init <dir>" (note the --bare as a git wrapper option), the setup code actually sets GIT_DIR for us, but it uses the wrong, original cwd when a directory is given. Because our setenv does not use the overwrite flag, it is ignored. We need to set the overwrite flag, but only when we are given a directory on the command line. That still allows: GIT_DIR=foo.git git init --bare to work. The behavior is changed for: GIT_DIR=foo.git git init --bare bar.git which used to create the repository in foo.git, but now will use bar.git. This is more sane, as command line options should generally override the environment. Noticed by Oliver Hoffmann. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t0001-init.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 675773479a..7c0a698b92 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