From 334afbc76fbd4a8d850946a2b450ba036365b554 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 23:44:19 +0000 Subject: tests: mark tests relying on the current default for `init.defaultBranch` 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 Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 't/t1400-update-ref.sh') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 4c01e08551..4ae6f50c02 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -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 -- cgit v1.2.3 From 06d531486e9078c88c324ad6f87376cfa897f058 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 23:44:21 +0000 Subject: t[01]*: adjust the references to the default branch name "main" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Carefully excluding t1309, which sees independent development elsewhere at the time of writing, we transition above-mentioned tests to the default branch name `main`. This trick was performed via $ (cd t && sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \ -e 's/Master/Main/g' -e 's/naster/nain/g' -- t[01]*.sh && git checkout HEAD -- t1309\*) Note that t5533 contains a variation of the name `master` (`naster`) that we rename here, too. This allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main` for those tests. Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 't/t1400-update-ref.sh') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 4ae6f50c02..1ad0bbbc53 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -4,14 +4,14 @@ # test_description='Test git update-ref and basic ref logging' -GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh Z=$ZERO_OID -m=refs/heads/master +m=refs/heads/main n_dir=refs/heads/gu n=$n_dir/fixes outside=refs/foo @@ -261,7 +261,7 @@ test_expect_success "(not) changed .git/$m" ' ! test $B = $(git show-ref -s --verify $m) ' -rm -f .git/logs/refs/heads/master +rm -f .git/logs/refs/heads/main test_expect_success "create $m (logged by touch)" ' test_config core.logAllRefUpdates false && GIT_COMMITTER_DATE="2005-05-26 23:30" \ @@ -297,7 +297,7 @@ test_expect_success 'symref empty directory removal' ' git branch e1/e2/r1 HEAD && git branch e1/r2 HEAD && git checkout e1/e2/r1 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && test_path_is_file .git/refs/heads/e1/e2/r1 && test_path_is_file .git/logs/refs/heads/e1/e2/r1 && git update-ref -d HEAD && @@ -361,68 +361,68 @@ test_expect_success 'set up for querying the reflog' ' ed="Thu, 26 May 2005 18:32:00 -0500" gd="Thu, 26 May 2005 18:33:00 -0500" ld="Thu, 26 May 2005 18:43:00 -0500" -test_expect_success 'Query "master@{May 25 2005}" (before history)' ' +test_expect_success 'Query "main@{May 25 2005}" (before history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{May 25 2005}" >o 2>e && + git rev-parse --verify "main@{May 25 2005}" >o 2>e && echo "$C" >expect && test_cmp expect o && - echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + echo "warning: log for '\''main'\'' only goes back to $ed" >expect && test_i18ncmp expect e ' -test_expect_success 'Query master@{2005-05-25} (before history)' ' +test_expect_success 'Query main@{2005-05-25} (before history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify master@{2005-05-25} >o 2>e && + git rev-parse --verify main@{2005-05-25} >o 2>e && echo "$C" >expect && test_cmp expect o && - echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + echo "warning: log for '\''main'\'' only goes back to $ed" >expect && test_i18ncmp expect e ' -test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' ' +test_expect_success 'Query "main@{May 26 2005 23:31:59}" (1 second before history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && + git rev-parse --verify "main@{May 26 2005 23:31:59}" >o 2>e && echo "$C" >expect && test_cmp expect o && - echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + echo "warning: log for '\''main'\'' only goes back to $ed" >expect && test_i18ncmp expect e ' -test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' ' +test_expect_success 'Query "main@{May 26 2005 23:32:00}" (exactly history start)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && + git rev-parse --verify "main@{May 26 2005 23:32:00}" >o 2>e && echo "$C" >expect && test_cmp expect o && test_must_be_empty e ' -test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' ' +test_expect_success 'Query "main@{May 26 2005 23:32:30}" (first non-creation change)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e && + git rev-parse --verify "main@{May 26 2005 23:32:30}" >o 2>e && echo "$A" >expect && test_cmp expect o && test_must_be_empty e ' -test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' ' +test_expect_success 'Query "main@{2005-05-26 23:33:01}" (middle of history with gap)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && + git rev-parse --verify "main@{2005-05-26 23:33:01}" >o 2>e && echo "$B" >expect && test_cmp expect o && test_i18ngrep -F "warning: log for ref $m has gap after $gd" e ' -test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' ' +test_expect_success 'Query "main@{2005-05-26 23:38:00}" (middle of history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && + git rev-parse --verify "main@{2005-05-26 23:38:00}" >o 2>e && echo "$Z" >expect && test_cmp expect o && test_must_be_empty e ' -test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' ' +test_expect_success 'Query "main@{2005-05-26 23:43:00}" (exact end of history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && + git rev-parse --verify "main@{2005-05-26 23:43:00}" >o 2>e && echo "$E" >expect && test_cmp expect o && test_must_be_empty e ' -test_expect_success 'Query "master@{2005-05-28}" (past end of history)' ' +test_expect_success 'Query "main@{2005-05-28}" (past end of history)' ' test_when_finished "rm -f o e" && - git rev-parse --verify "master@{2005-05-28}" >o 2>e && + git rev-parse --verify "main@{2005-05-28}" >o 2>e && echo "$D" >expect && test_cmp expect o && test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e @@ -464,14 +464,14 @@ test_expect_success 'git commit logged updates' ' ' unset h_TEST h_OTHER h_FIXED h_MERGED -test_expect_success 'git cat-file blob master:F (expect OTHER)' ' - test OTHER = $(git cat-file blob master:F) +test_expect_success 'git cat-file blob main:F (expect OTHER)' ' + test OTHER = $(git cat-file blob main:F) ' -test_expect_success 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' ' - test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F") +test_expect_success 'git cat-file blob main@{2005-05-26 23:30}:F (expect TEST)' ' + test TEST = $(git cat-file blob "main@{2005-05-26 23:30}:F") ' -test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' ' - test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F") +test_expect_success 'git cat-file blob main@{2005-05-26 23:42}:F (expect OTHER)' ' + test OTHER = $(git cat-file blob "main@{2005-05-26 23:42}:F") ' # Test adding and deleting pseudorefs @@ -583,9 +583,9 @@ test_expect_success 'stdin fails on unknown command' ' ' test_expect_success 'stdin fails on unbalanced quotes' ' - echo "create $a \"master" >stdin && + echo "create $a \"main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: badly quoted argument: \\\"master" err + grep "fatal: badly quoted argument: \\\"main" err ' test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' ' @@ -595,9 +595,9 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' ' ' test_expect_success 'stdin fails on junk after quoted argument' ' - echo "create \"$a\"master" >stdin && + echo "create \"$a\"main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err + grep "fatal: unexpected character after quoted argument: \\\"$a\\\"main" err ' test_expect_success 'stdin fails create with no ref' ' -- cgit v1.2.3 From 8b70966aa90b52427e1a09329abde8d845f90398 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 23:44:46 +0000 Subject: tests: drop prereq `PREPARE_FOR_MAIN_BRANCH` where no longer needed We introduced the `PREPARE_FOR_MAIN_BRANCH` prereq for the sole purpose of allowing us to perform the non-trivial adjustments regarding the `master` -> `main` rename before the automatable ones. Now that the transition is almost complete, we can stop using it in most instances. The only two exceptions are t5526 and t9902: at the time of writing, there are other patches in flight that touch these test scripts, therefore their transition to `main` is postponed to a later date. This patch is the result of this command: sed -i 's/PREPARE_FOR_MAIN_BRANCH[ ,]//' t/t[0-9]*.sh && git checkout HEAD -- t/t5526\* t/t9902\* Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t1400-update-ref.sh') diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 1ad0bbbc53..e7cd4917d1 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -588,7 +588,7 @@ test_expect_success 'stdin fails on unbalanced quotes' ' grep "fatal: badly quoted argument: \\\"main" err ' -test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' ' +test_expect_success 'stdin fails on invalid escape' ' echo "create $a \"ma\zn\"" >stdin && test_must_fail git update-ref --stdin err && grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err @@ -707,7 +707,7 @@ test_expect_success 'stdin succeeds with quoted argument' ' test_cmp expect actual ' -test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin succeeds with escaped character' ' +test_expect_success 'stdin succeeds with escaped character' ' git update-ref -d $a && echo "create $a \"ma\\151n\"" >stdin && git update-ref --stdin