diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2020-06-24 16:46:32 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-06-24 18:14:21 +0200 |
commit | 32ba12dab2acf1ad11836a627956d1473f6b851a (patch) | |
tree | ca58c7b1e3224c5f816c6f0bf1327d873a798a40 /t/t0001-init.sh | |
parent | docs: add missing diamond brackets (diff) | |
download | git-32ba12dab2acf1ad11836a627956d1473f6b851a.tar.xz git-32ba12dab2acf1ad11836a627956d1473f6b851a.zip |
init: allow specifying the initial branch name for the new repository
There is a growing number of projects and companies desiring to change
the main branch name of their repositories (see e.g.
https://twitter.com/mislav/status/1270388510684598272 for background on
this).
To change that branch name for new repositories, currently the only way
to do that automatically is by copying all of Git's template directory,
then hard-coding the desired default branch name into the `.git/HEAD`
file, and then configuring `init.templateDir` to point to those copied
template files.
To make this process much less cumbersome, let's introduce a new option:
`--initial-branch=<branch-name>`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rwxr-xr-x | t/t0001-init.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 1edd5aeb8f..386c06b5dd 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -464,4 +464,17 @@ test_expect_success MINGW 'redirect std handles' ' grep "Needed a single revision" output.txt ' +test_expect_success '--initial-branch' ' + git init --initial-branch=hello initial-branch-option && + git -C initial-branch-option symbolic-ref HEAD >actual && + echo refs/heads/hello >expect && + test_cmp expect actual && + + : re-initializing should not change the branch name && + git init --initial-branch=ignore initial-branch-option 2>err && + test_i18ngrep "ignored --initial-branch" err && + git -C initial-branch-option symbolic-ref HEAD >actual && + grep hello actual +' + test_done |