Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t6009-rev-list-parent.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t6009-rev-list-parent.sh` 163 lines ยท 4253 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='ancestor culling and limiting by parent number' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 check_revlist () { 11 rev_list_args="$1" && 12 shift && 13 git rev-parse "$@" >expect && 14 git rev-list $rev_list_args --all >actual && 15 test_cmp expect actual 16 } 17 18 test_expect_success setup ' 19 20 touch file && 21 git add file && 22 23 test_commit one && 24 25 test_tick=$(($test_tick - 2400)) && 26 27 test_commit two && 28 test_commit three && 29 test_commit four && 30 31 git log --pretty=oneline --abbrev-commit 32 ' 33 34 test_expect_success 'one is ancestor of others and should not be shown' ' 35 36 git rev-list one --not four >result && 37 test_must_be_empty result 38 39 ' 40 41 test_expect_success 'setup roots, merges and octopuses' ' 42 43 git checkout --orphan newroot && 44 test_commit five && 45 git checkout -b sidebranch two && 46 test_commit six && 47 git checkout -b anotherbranch three && 48 test_commit seven && 49 git checkout -b yetanotherbranch four && 50 test_commit eight && 51 git checkout main && 52 test_tick && 53 git merge --allow-unrelated-histories -m normalmerge newroot && 54 git tag normalmerge && 55 test_tick && 56 git merge -m tripus sidebranch anotherbranch && 57 git tag tripus && 58 git checkout -b tetrabranch normalmerge && 59 test_tick && 60 git merge -m tetrapus sidebranch anotherbranch yetanotherbranch && 61 git tag tetrapus && 62 git checkout main 63 ' 64 65 test_expect_success 'parse --max-parents & --min-parents' ' 66 test_must_fail git rev-list --max-parents=1q HEAD 2>error && 67 test_grep "not an integer" error && 68 69 test_must_fail git rev-list --min-parents=1q HEAD 2>error && 70 test_grep "not an integer" error && 71 72 git rev-list --max-parents=1 --min-parents=1 HEAD && 73 git rev-list --max-parents=-1 --min-parents=-1 HEAD 74 ' 75 76 test_expect_success 'rev-list roots' ' 77 78 check_revlist "--max-parents=0" one five 79 ' 80 81 test_expect_success 'rev-list no merges' ' 82 83 check_revlist "--max-parents=1" one eight seven six five four three two && 84 check_revlist "--no-merges" one eight seven six five four three two 85 ' 86 87 test_expect_success 'rev-list no octopuses' ' 88 89 check_revlist "--max-parents=2" one normalmerge eight seven six five four three two 90 ' 91 92 test_expect_success 'rev-list no roots' ' 93 94 check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two 95 ' 96 97 test_expect_success 'rev-list merges' ' 98 99 check_revlist "--min-parents=2" tetrapus tripus normalmerge && 100 check_revlist "--merges" tetrapus tripus normalmerge 101 ' 102 103 test_expect_success 'rev-list octopus' ' 104 105 check_revlist "--min-parents=3" tetrapus tripus 106 ' 107 108 test_expect_success 'rev-list ordinary commits' ' 109 110 check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two 111 ' 112 113 test_expect_success 'rev-list --merges --no-merges yields empty set' ' 114 115 check_revlist "--min-parents=2 --no-merges" && 116 check_revlist "--merges --no-merges" && 117 check_revlist "--no-merges --merges" 118 ' 119 120 test_expect_success 'rev-list override and infinities' ' 121 122 check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge && 123 check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge && 124 check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge && 125 check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge && 126 check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge && 127 check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five 128 ' 129 130 test_expect_success 'dodecapus' ' 131 132 roots= && 133 for i in 1 2 3 4 5 6 7 8 9 10 11 134 do 135 git checkout -b root$i five && 136 test_commit $i && 137 roots="$roots root$i" || 138 return 1 139 done && 140 git checkout main && 141 test_tick && 142 git merge -m dodecapus $roots && 143 git tag dodecapus && 144 145 check_revlist "--min-parents=4" dodecapus tetrapus && 146 check_revlist "--min-parents=8" dodecapus && 147 check_revlist "--min-parents=12" dodecapus && 148 check_revlist "--min-parents=13" && 149 check_revlist "--min-parents=4 --max-parents=11" tetrapus 150 ' 151 152 test_expect_success 'ancestors with the same commit time' ' 153 154 test_tick_keep=$test_tick && 155 for i in 1 2 3 4 5 6 7 8; do 156 test_tick=$test_tick_keep && 157 test_commit t$i || return 1 158 done && 159 git rev-list t1^! --not t$i >result && 160 test_must_be_empty result 161 ' 162 163 test_done