1
0
mirror of https://github.com/git/git.git synced 2024-09-28 20:51:42 +02:00
git/t/t5606-clone-options.sh
Johannes Schindelin 0cc1b475bb clone: use configured default branch name when appropriate
When cloning a repository without any branches, Git chooses a default
branch name for the as-yet unborn branch.

As part of the implicit initialization of the local repository, Git just
learned to respect `init.defaultBranch` to choose a different initial
branch name. We now really want that branch name to be used as a
fall-back.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-06-24 09:14:21 -07:00

54 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
test_description='basic clone options'
. ./test-lib.sh
test_expect_success 'setup' '
mkdir parent &&
(cd parent && git init &&
echo one >file && git add file &&
git commit -m one)
'
test_expect_success 'clone -o' '
git clone -o foo parent clone-o &&
(cd clone-o && git rev-parse --verify refs/remotes/foo/master)
'
test_expect_success 'redirected clone does not show progress' '
git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
! grep % err &&
test_i18ngrep ! "Checking connectivity" err
'
test_expect_success 'redirected clone -v does show progress' '
git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
>out 2>err &&
grep % err
'
test_expect_success 'chooses correct default initial branch name' '
git init --bare empty &&
git -c init.defaultBranch=up clone empty whats-up &&
test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) &&
test refs/heads/up = $(git -C whats-up config branch.up.merge)
'
test_expect_success 'guesses initial branch name correctly' '
git init --initial-branch=guess initial-branch &&
test_commit -C initial-branch no-spoilers &&
git -C initial-branch branch abc guess &&
git clone initial-branch is-it &&
test refs/heads/guess = $(git -C is-it symbolic-ref HEAD)
'
test_done