From: Junio C Hamano Date: Mon, 25 Jan 2021 22:19:18 +0000 (-0800) Subject: Merge branch 'js/default-branch-name-tests-final-stretch' X-Git-Tag: v2.31.0-rc0~102 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27d7c8599b;p=thirdparty%2Fgit.git Merge branch 'js/default-branch-name-tests-final-stretch' Prepare tests not to be affected by the name of the default branch "git init" creates. * js/default-branch-name-tests-final-stretch: (28 commits) tests: drop prereq `PREPARE_FOR_MAIN_BRANCH` where no longer needed t99*: adjust the references to the default branch name "main" tests(git-p4): transition to the default branch name `main` t9[5-7]*: adjust the references to the default branch name "main" t9[0-4]*: adjust the references to the default branch name "main" t8*: adjust the references to the default branch name "main" t7[5-9]*: adjust the references to the default branch name "main" t7[0-4]*: adjust the references to the default branch name "main" t6[4-9]*: adjust the references to the default branch name "main" t64*: preemptively adjust alignment to prepare for `master` -> `main` t6[0-3]*: adjust the references to the default branch name "main" t5[6-9]*: adjust the references to the default branch name "main" t55[4-9]*: adjust the references to the default branch name "main" t55[23]*: adjust the references to the default branch name "main" t551*: adjust the references to the default branch name "main" t550*: adjust the references to the default branch name "main" t5503: prepare aligned comment for replacing `master` with `main` t5[0-4]*: adjust the references to the default branch name "main" t5323: prepare centered comment for `master` -> `main` t4*: adjust the references to the default branch name "main" ... --- 27d7c8599b159862762e2bd121c22d516fb04e90 diff --cc t/t1500-rev-parse.sh index 51d7d40ec1,9e911e0054..abdda360d5 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@@ -1,18 -1,11 +1,21 @@@ #!/bin/sh test_description='test git rev-parse' + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +test_one () { + dir="$1" && + expect="$2" && + shift && + shift && + echo "$expect" >expect && + git -C "$dir" rev-parse "$@" >actual && + test_cmp expect actual +} + # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir absolute-git-dir test_rev_parse () { d= diff --cc t/t1508-at-combinations.sh index e4521b7b97,17421a368d..87a4286414 --- a/t/t1508-at-combinations.sh +++ b/t/t1508-at-combinations.sh @@@ -99,17 -102,4 +102,17 @@@ test_expect_success 'create path with @ check "@:normal" blob content check "@:fun@ny" blob content +test_expect_success '@{1} works with only one reflog entry' ' - git checkout -B newbranch master && ++ git checkout -B newbranch main && + git reflog expire --expire=now refs/heads/newbranch && + git commit --allow-empty -m "first after expiration" && + test_cmp_rev newbranch~ newbranch@{1} +' + +test_expect_success '@{0} works with empty reflog' ' - git checkout -B newbranch master && ++ git checkout -B newbranch main && + git reflog expire --expire=now refs/heads/newbranch && + test_cmp_rev newbranch newbranch@{0} +' + test_done diff --cc t/t4014-format-patch.sh index c5e5e0da3f,af67c46cd3..66630c8413 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@@ -313,63 -316,9 +316,63 @@@ test_expect_success 'multiple files' ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch ' +test_expect_success 'filename length limit' ' + test_when_finished "rm -f 000*" && + rm -rf 000[1-9]-*.patch && + for len in 15 25 35 + do + git format-patch --filename-max-length=$len -3 side && + max=$( + for patch in 000[1-9]-*.patch + do + echo "$patch" | wc -c + done | + sort -nr | + head -n 1 + ) && + test $max -le $len || return 1 + done +' + +test_expect_success 'filename length limit from config' ' + test_when_finished "rm -f 000*" && + rm -rf 000[1-9]-*.patch && + for len in 15 25 35 + do + git -c format.filenameMaxLength=$len format-patch -3 side && + max=$( + for patch in 000[1-9]-*.patch + do + echo "$patch" | wc -c + done | + sort -nr | + head -n 1 + ) && + test $max -le $len || return 1 + done +' + +test_expect_success 'filename limit applies only to basename' ' + test_when_finished "rm -rf patches/" && + rm -rf patches/ && + for len in 15 25 35 + do + git format-patch -o patches --filename-max-length=$len -3 side && + max=$( + for patch in patches/000[1-9]-*.patch + do + echo "${patch#patches/}" | wc -c + done | + sort -nr | + head -n 1 + ) && + test $max -le $len || return 1 + done +' + test_expect_success 'reroll count' ' rm -fr patches && - git format-patch -o patches --cover-letter --reroll-count 4 master..side >list && + git format-patch -o patches --cover-letter --reroll-count 4 main..side >list && ! grep -v "^patches/v4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects diff --cc t/t5323-pack-redundant.sh index 543cb4c6a8,89c8688647..8b01793845 --- a/t/t5323-pack-redundant.sh +++ b/t/t5323-pack-redundant.sh @@@ -36,11 -36,9 +36,11 @@@ relationship between packs and objects . ./test-lib.sh - master_repo=master.git + main_repo=main.git shared_repo=shared.git +git_pack_redundant='git pack-redundant --i-still-use-this' + # Create commits in and assign each commit's oid to shell variables # given in the arguments (A, B, and C). E.g.: # @@@ -109,34 -107,25 +109,34 @@@ format_packfiles () sort } - test_expect_success 'setup master repo' ' - git init --bare "$master_repo" && - create_commits_in "$master_repo" A B C D E F G H I J K L M N O P Q R + test_expect_success 'setup main repo' ' + git init --bare "$main_repo" && + create_commits_in "$main_repo" A B C D E F G H I J K L M N O P Q R ' +test_expect_success 'master: pack-redundant works with no packfile' ' + ( + cd "$master_repo" && + cat >expect <<-EOF && + fatal: Zero packs found! + EOF + test_must_fail $git_pack_redundant --all >actual 2>&1 && + test_cmp expect actual + ) +' + ############################################################################# # Chart of packs and objects for this test case # # | T A B C D E F G H I J K L M N O P Q R # ----+-------------------------------------- # P1 | x x x x x x x x -# P2 | x x x x x x x -# P3 | x x x x x x # ----+-------------------------------------- -# ALL | x x x x x x x x x x x x x x x +# ALL | x x x x x x x x # ############################################################################# - test_expect_success 'master: pack-redundant works with one packfile' ' - create_pack_in "$master_repo" P1 <<-EOF && -test_expect_success 'main: no redundant for pack 1, 2, 3' ' ++test_expect_success 'main: pack-redundant works with one packfile' ' + create_pack_in "$main_repo" P1 <<-EOF && $T $A $B @@@ -146,27 -135,7 +146,27 @@@ $F $R EOF + ( - cd "$master_repo" && ++ cd "$main_repo" && + $git_pack_redundant --all >out && + test_must_be_empty out + ) +' + +############################################################################# +# Chart of packs and objects for this test case +# +# | T A B C D E F G H I J K L M N O P Q R +# ----+-------------------------------------- +# P1 | x x x x x x x x +# P2 | x x x x x x x +# P3 | x x x x x x +# ----+-------------------------------------- +# ALL | x x x x x x x x x x x x x x x +# +############################################################################# - test_expect_success 'master: no redundant for pack 1, 2, 3' ' - create_pack_in "$master_repo" P2 <<-EOF && ++test_expect_success 'main: no redundant for pack 1, 2, 3' ' + create_pack_in "$main_repo" P2 <<-EOF && $B $C $D @@@ -184,8 -153,8 +184,8 @@@ $M EOF ( - cd "$master_repo" && + cd "$main_repo" && - git pack-redundant --all >out && + $git_pack_redundant --all >out && test_must_be_empty out ) ' @@@ -312,12 -281,12 +312,12 @@@ test_expect_success 'main: clean loose ) ' - test_expect_success 'master: remove redundant packs and pass fsck' ' + test_expect_success 'main: remove redundant packs and pass fsck' ' ( - cd "$master_repo" && + cd "$main_repo" && - git pack-redundant --all | xargs rm && + $git_pack_redundant --all | xargs rm && git fsck && - git pack-redundant --all >out && + $git_pack_redundant --all >out && test_must_be_empty out ) ' diff --cc t/t5516-fetch-push.sh index 3ed121d0ce,b037439c49..15262b4192 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@@ -436,83 -439,77 +439,76 @@@ test_expect_success 'push ref expressio ' -test_expect_success 'push with HEAD' ' - - mk_test testrepo heads/main && - git checkout main && - git push testrepo HEAD && - check_push_result testrepo $the_commit heads/main - -' - -test_expect_success 'push with HEAD nonexisting at remote' ' - - mk_test testrepo heads/main && - git checkout -b local main && - git push testrepo HEAD && - check_push_result testrepo $the_commit heads/local -' - -test_expect_success 'push with +HEAD' ' +for head in HEAD @ +do - mk_test testrepo heads/main && - git checkout main && - git branch -D local && - git checkout -b local && - git push testrepo main local && - check_push_result testrepo $the_commit heads/main && - check_push_result testrepo $the_commit heads/local && + test_expect_success "push with $head" ' - - mk_test testrepo heads/master && - git checkout master && ++ mk_test testrepo heads/main && ++ git checkout main && + git push testrepo $head && - check_push_result testrepo $the_commit heads/master - ++ check_push_result testrepo $the_commit heads/main + ' - # Without force rewinding should fail - git reset --hard HEAD^ && - test_must_fail git push testrepo HEAD && - check_push_result testrepo $the_commit heads/local && + test_expect_success "push with $head nonexisting at remote" ' - - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && ++ mk_test testrepo heads/main && ++ git checkout -b local main && ++ test_when_finished "git checkout main; git branch -D local" && + git push testrepo $head && + check_push_result testrepo $the_commit heads/local + ' - # With force rewinding should succeed - git push testrepo +HEAD && - check_push_result testrepo $the_first_commit heads/local + test_expect_success "push with +$head" ' - - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && - git push testrepo master local && - check_push_result testrepo $the_commit heads/master && ++ mk_test testrepo heads/main && ++ git checkout -b local main && ++ test_when_finished "git checkout main; git branch -D local" && ++ git push testrepo main local && ++ check_push_result testrepo $the_commit heads/main && + check_push_result testrepo $the_commit heads/local && -' + # Without force rewinding should fail + git reset --hard $head^ && + test_must_fail git push testrepo $head && + check_push_result testrepo $the_commit heads/local && -test_expect_success 'push HEAD with non-existent, incomplete dest' ' + # With force rewinding should succeed + git push testrepo +$head && + check_push_result testrepo $the_first_commit heads/local - + ' - mk_test testrepo && - git checkout main && - git push testrepo HEAD:branch && - check_push_result testrepo $the_commit heads/branch + test_expect_success "push $head with non-existent, incomplete dest" ' - + mk_test testrepo && - git checkout master && ++ git checkout main && + git push testrepo $head:branch && + check_push_result testrepo $the_commit heads/branch -' + ' -test_expect_success 'push with config remote.*.push = HEAD' ' + test_expect_success "push with config remote.*.push = $head" ' - + mk_test testrepo heads/local && - git checkout master && ++ git checkout main && + git branch -f local $the_commit && + test_when_finished "git branch -D local" && + ( + cd testrepo && + git checkout local && + git reset --hard $the_first_commit + ) && + test_config remote.there.url testrepo && + test_config remote.there.push $head && - test_config branch.master.remote there && ++ test_config branch.main.remote there && + git push && - check_push_result testrepo $the_commit heads/master && ++ check_push_result testrepo $the_commit heads/main && + check_push_result testrepo $the_first_commit heads/local + ' - mk_test testrepo heads/local && - git checkout main && - git branch -f local $the_commit && - ( - cd testrepo && - git checkout local && - git reset --hard $the_first_commit - ) && - test_config remote.there.url testrepo && - test_config remote.there.push HEAD && - test_config branch.main.remote there && - git push && - check_push_result testrepo $the_commit heads/main && - check_push_result testrepo $the_first_commit heads/local -' +done test_expect_success 'push with remote.pushdefault' ' - mk_test up_repo heads/master && - mk_test down_repo heads/master && + mk_test up_repo heads/main && + mk_test down_repo heads/main && test_config remote.up.url up_repo && test_config remote.down.url down_repo && - test_config branch.master.remote up && + test_config branch.main.remote up && test_config remote.pushdefault down && test_config push.default matching && git push && diff --cc t/t5572-pull-submodule.sh index 37fd06b0be,d6a75964d8..29537f4798 --- a/t/t5572-pull-submodule.sh +++ b/t/t5572-pull-submodule.sh @@@ -144,50 -136,6 +144,50 @@@ test_expect_success 'pull --rebase --re test_i18ngrep "locally recorded submodule modifications" err ' +test_expect_success 'pull --rebase --recurse-submodules (no submodule changes, no fork-point)' ' + # This tests the following scenario : + # - local submodule does not have new commits + # - local superproject has new commits that *do not* change the submodule pointer + # - upstream superproject has new commits that *do not* change the submodule pointer + # - local superproject branch has no fork-point with its remote-tracking counter-part + + # create upstream superproject + test_create_repo submodule && + test_commit -C submodule first_in_sub && + + test_create_repo superprojet && + test_commit -C superprojet first_in_super && + git -C superprojet submodule add ../submodule && + git -C superprojet commit -m "add submodule" && + test_commit -C superprojet third_in_super && + + # clone superproject + git clone --recurse-submodules superprojet superclone && + + # add commits upstream + test_commit -C superprojet fourth_in_super && + + # create topic branch in clone, not based on any remote-tracking branch + git -C superclone checkout -b feat HEAD~1 && + test_commit -C superclone first_on_feat && - git -C superclone pull --rebase --recurse-submodules origin master ++ git -C superclone pull --rebase --recurse-submodules origin HEAD +' + +# NOTE: +# +# This test is particular because there is only a single commit in the upstream superproject +# 'parent' (which adds the submodule 'a-submodule'). The clone of the superproject +# ('child') hard-resets its branch to a new root commit with the same tree as the one +# from the upstream superproject, so that its branch has no merge-base with its +# remote-tracking counterpart, and then calls 'git pull --recurse-submodules --rebase'. +# The result is that the local branch is reset to the remote-tracking branch (as it was +# originally before the hard-reset). + +# The only commit in the range generated by 'submodule.c::submodule_touches_in_range' and +# passed to 'submodule.c::collect_changed_submodules' is the new (regenerated) initial commit, +# which adds the submodule. +# However, 'submodule_touches_in_range' does not error (even though this commit adds the submodule) +# because 'combine-diff.c::diff_tree_combined' returns early, as the initial commit has no parents. test_expect_success 'branch has no merge base with remote-tracking counterpart' ' rm -rf parent child && @@@ -200,8 -148,8 +200,8 @@@ git clone parent child && - # Reset master so that it has no merge base with - # refs/remotes/origin/master. - # Reset main so that it has no merge base with - # refs/remotes/origin/main. ++ # Reset the current branch so that it has no merge base with ++ # the remote-tracking branch. OTHER=$(git -C child commit-tree -m bar \ $(git -C child rev-parse HEAD^{tree})) && git -C child reset --hard "$OTHER" && diff --cc t/t6016-rev-list-graph-simplify-history.sh index f79df8b6d1,6eddbbcc9f..54b0a6f5f8 --- a/t/t6016-rev-list-graph-simplify-history.sh +++ b/t/t6016-rev-list-graph-simplify-history.sh @@@ -7,13 -7,10 +7,16 @@@ test_description='--graph and simplified history' + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-log-graph.sh + +check_graph () { + cat >expect && + lib_test_cmp_graph --format=%s "$@" +} test_expect_success 'set up rev-list --graph test' ' # 3 commits on branch A