Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2021-03-10 04:11:20 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-11 02:06:48 +0300
commit75555676ad3908b0f847a9ae154c35e12114c82f (patch)
tree30d4d80bb69e8c1091cbdb5e0e7a5dad2d76a90f /t/t5606-clone-options.sh
parent71ca53e8125e36efbda17293c50027d31681a41f (diff)
builtin/init-db: handle bare clones when core.bare set to false
In 552955ed7f ("clone: use more conventional config/option layering", 2020-10-01), clone learned to read configuration options earlier in its execution, before creating the new repository. However, that led to a problem: if the core.bare setting is set to false in the global config, cloning a bare repository segfaults. This happens because the repository is falsely thought to be non-bare, but clone has set the work tree to NULL, which is then dereferenced. The code to initialize the repository already considers the fact that a user might want to override the --bare option for git init, but it doesn't take into account clone, which uses a different option. Let's just check that the work tree is not NULL, since that's how clone indicates that the repository is bare. This is also the case for git init, so we won't be regressing that case. Reported-by: Joseph Vusich <jvusich@amazon.com> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5606-clone-options.sh')
-rwxr-xr-xt/t5606-clone-options.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh
index 7f082fb23b..88349343e8 100755
--- a/t/t5606-clone-options.sh
+++ b/t/t5606-clone-options.sh
@@ -101,6 +101,14 @@ test_expect_success 'redirected clone -v does show progress' '
'
+test_expect_success 'clone does not segfault with --bare and core.bare=false' '
+ test_config_global core.bare false &&
+ git clone --bare parent clone-bare &&
+ echo true >expect &&
+ git -C clone-bare rev-parse --is-bare-repository >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'chooses correct default initial branch name' '
git init --bare empty &&
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \