Skip to content

Commit

Permalink
tests: mark tests relying on the current default for `init.defaultBra…
Browse files Browse the repository at this point in the history
…nch`

In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.

To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in

- all test scripts that contain the keyword `master`,

- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
  initialize the default branch,

- t5560 because it sources `t/t556x_common` which uses `master`,

- t8002 and t8012 because both source `t/annotate-tests.sh` which also
  uses `master`)

This trick was performed by this command:

	$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
	GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
	' $(git grep -l master t/t[0-9]*.sh) \
	t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh

After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:

	$ git checkout HEAD -- \
		t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
		t/t1011-read-tree-sparse-checkout.sh \
		t/t1305-config-include.sh t/t1309-early-config.sh \
		t/t1402-check-ref-format.sh t/t1450-fsck.sh \
		t/t2024-checkout-dwim.sh \
		t/t2106-update-index-assume-unchanged.sh \
		t/t3040-subprojects-basic.sh t/t3301-notes.sh \
		t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
		t/t3436-rebase-more-options.sh \
		t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
		t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
		t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
		t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
		t/t5548-push-porcelain.sh \
		t/t5552-skipping-fetch-negotiator.sh \
		t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
		t/t5614-clone-submodules-shallow.sh \
		t/t7508-status.sh t/t7606-merge-custom.sh \
		t/t9302-fast-import-unpack-limit.sh

We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:

	$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
	GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
	' t/t980[0167]*.sh t/t9811*.sh

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Nov 19, 2020
1 parent fced6d1 commit 334afbc
Show file tree
Hide file tree
Showing 325 changed files with 974 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ci/run-build-and-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ esac
make
case "$jobname" in
linux-gcc)
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
make test
export GIT_TEST_SPLIT_INDEX=yes
export GIT_TEST_FULL_IN_PACK_ARRAY=true
Expand All @@ -22,6 +23,7 @@ linux-gcc)
export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
export GIT_TEST_MULTI_PACK_INDEX=1
export GIT_TEST_ADD_I_USE_BUILTIN=1
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
make test
;;
linux-clang)
Expand Down
3 changes: 3 additions & 0 deletions t/t0002-gitfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test_description='.git file
Verify that plumbing commands work when .git is a file
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

objpath() {
Expand Down
3 changes: 3 additions & 0 deletions t/t0020-crlf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='CRLF conversion'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

has_cr() {
Expand Down
3 changes: 3 additions & 0 deletions t/t0021-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='blob conversion via gitattributes'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

TEST_ROOT="$PWD"
Expand Down
3 changes: 3 additions & 0 deletions t/t0028-working-tree-encoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='working-tree-encoding conversion via gitattributes'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING
Expand Down
3 changes: 3 additions & 0 deletions t/t0041-usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='Test commands behavior when given invalid argument value'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'setup ' '
Expand Down
3 changes: 3 additions & 0 deletions t/t0050-filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='Various filesystem issues'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

auml=$(printf '\303\244')
Expand Down
3 changes: 3 additions & 0 deletions t/t0100-previous.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='previous branch syntax @{-n}'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'branch -d @{-1}' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1004-read-tree-m-u-wf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='read-tree -m -u checks working tree files'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

Expand Down
3 changes: 3 additions & 0 deletions t/t1008-read-tree-overlay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test multi-tree read-tree without merging'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

Expand Down
3 changes: 3 additions & 0 deletions t/t1009-read-tree-new-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test read-tree into a fresh index file'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1021-rerere-in-workdir.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='rerere run in a workdir'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success SYMLINKS setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1090-sparse-checkout-scope.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='sparse checkout scope tests'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'setup' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1091-sparse-checkout-builtin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='sparse checkout builtin tests'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

list_files() {
Expand Down
3 changes: 3 additions & 0 deletions t/t1300-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

test_description='Test git config in different settings'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'clear default config' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1301-shared-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

test_description='Test shared repository initialization'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

# Remove a default ACL from the test dir if possible.
Expand Down
3 changes: 3 additions & 0 deletions t/t1400-update-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#

test_description='Test git update-ref and basic ref logging'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

Z=$ZERO_OID
Expand Down
3 changes: 3 additions & 0 deletions t/t1403-show-ref.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='show-ref'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1405-main-ref-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test main ref store api'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

RUN="test-tool ref-store main"
Expand Down
3 changes: 3 additions & 0 deletions t/t1406-submodule-ref-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test submodule ref store api'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

RUN="test-tool ref-store submodule:sub"
Expand Down
3 changes: 3 additions & 0 deletions t/t1407-worktree-ref-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test worktree ref store api'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

RWT="test-tool ref-store worktree:wt"
Expand Down
3 changes: 3 additions & 0 deletions t/t1408-packed-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='packed-refs entries are covered by loose refs'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1410-reflog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#

test_description='Test prune and reflog expiration'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

check_have () {
Expand Down
3 changes: 3 additions & 0 deletions t/t1411-reflog-show.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='Test reflog display routines'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'setup' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1413-reflog-detach.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='Test reflog interaction with detached HEAD'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

reset_state () {
Expand Down
3 changes: 3 additions & 0 deletions t/t1414-reflog-walk.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='various tests of reflog walk (log -g) behavior'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'set up some reflog entries' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1416-ref-transaction-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='reference transaction hooks'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1430-bad-ref-name.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='Test handling of ref names that check-ref-format rejects'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success setup '
Expand Down
3 changes: 3 additions & 0 deletions t/t1500-rev-parse.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='test git rev-parse'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

# usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir absolute-git-dir
Expand Down
3 changes: 3 additions & 0 deletions t/t1503-rev-parse-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ test_description='test git rev-parse --verify'

exec </dev/null

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

add_line_into_file()
Expand Down
3 changes: 3 additions & 0 deletions t/t1505-rev-parse-last.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test @{-N} syntax'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh


Expand Down
3 changes: 3 additions & 0 deletions t/t1506-rev-parse-diagnosis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test_description='test git rev-parse diagnosis for invalid argument'

exec </dev/null

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_did_you_mean ()
Expand Down
3 changes: 3 additions & 0 deletions t/t1507-rev-parse-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='test <branch>@{upstream} syntax'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh


Expand Down
3 changes: 3 additions & 0 deletions t/t1508-at-combinations.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='test various @{X} syntax combinations together'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

check() {
Expand Down
3 changes: 3 additions & 0 deletions t/t1511-rev-parse-caret.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='tests for ref^{stuff}'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'setup' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1512-rev-parse-disambiguation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ one tagged as v1.0.0. They all have one regular file each.
'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

if ! test_have_prereq SHA1
Expand Down
3 changes: 3 additions & 0 deletions t/t1513-rev-parse-prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='Tests for rev-parse --prefix'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

test_expect_success 'setup' '
Expand Down
3 changes: 3 additions & 0 deletions t/t1514-rev-parse-push.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

test_description='test <branch>@{push} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

resolve () {
Expand Down
3 changes: 3 additions & 0 deletions t/t1700-split-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

test_description='split index mode tests'

GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

. ./test-lib.sh

# We need total control of index splitting here
Expand Down

0 comments on commit 334afbc

Please sign in to comment.