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/t6012-rev-list-simplify.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 / t6012-rev-list-simplify.sh` 306 lines ยท 7596 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='merge simplification' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 note () { 11 git tag "$1" 12 } 13 14 unnote () { 15 test_when_finished "rm -f tmp" && 16 git name-rev --tags --annotate-stdin >tmp && 17 sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" file && 37 echo "initial" >lost && 38 git add file lost && 39 test_tick && git commit -m "Initial file and lost" && 40 note A && 41 42 git branch other-branch && 43 44 git symbolic-ref HEAD refs/heads/unrelated && 45 git rm -f "*" && 46 echo "Unrelated branch" >side && 47 git add side && 48 test_tick && git commit -m "Side root" && 49 note J && 50 git checkout main && 51 52 echo "Hello" >file && 53 echo "second" >lost && 54 git add file lost && 55 test_tick && GIT_AUTHOR_DATE=$(($test_tick + 120)) git commit -m "Modified file and lost" && 56 note B && 57 58 git checkout other-branch && 59 60 echo "Hello" >file && 61 >lost && 62 git add file lost && 63 test_tick && git commit -m "Modified the file identically" && 64 note C && 65 66 echo "This is a stupid example" >another-file && 67 git add another-file && 68 test_tick && git commit -m "Add another file" && 69 note D && 70 71 test_tick && 72 test_must_fail git merge -m "merge" main && 73 >lost && git commit -a -m "merge" && 74 note E && 75 76 echo "Yet another" >elif && 77 git add elif && 78 test_tick && git commit -m "Irrelevant change" && 79 note F && 80 81 git checkout main && 82 echo "Yet another" >elif && 83 git add elif && 84 test_tick && git commit -m "Another irrelevant change" && 85 note G && 86 87 test_tick && git merge -m "merge" other-branch && 88 note H && 89 90 echo "Final change" >file && 91 test_tick && git commit -a -m "Final change" && 92 note I && 93 94 git checkout main && 95 test_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated && 96 note K && 97 98 echo "Immaterial" >elif && 99 git add elif && 100 test_tick && git commit -m "Last" && 101 note L 102 ' 103 104 FMT='tformat:%P %H | %s' 105 106 check_outcome () { 107 outcome=$1 108 shift 109 for c in $1 110 do 111 echo "$c" 112 done >expect && 113 shift && 114 param="$*" && 115 test_expect_$outcome "log $param" ' 116 git log --pretty="$FMT" --parents $param >out && 117 unnote >actual check expect && 156 git log --pretty="$FMT" --full-history E -- lost >out && 157 unnote >actual check expected && 164 git log -p --pretty="%H" --full-diff --parents -- file >actual && 165 test_cmp expected actual 166 ' 167 168 # 169 # Create a new history to demonstrate the value of --show-pulls 170 # with respect to the subtleties of simplified history, --full-history, 171 # and --simplify-merges. 172 # 173 # .-A---M-----C--N---O---P 174 # / / \ \ \/ / / 175 # I B \ R-'`-Z' / 176 # \ / \/ / 177 # \ / /\ / 178 # `---X--' `---Y--' 179 # 180 # This example is explained in Documentation/rev-list-options.adoc 181 182 test_expect_success 'setup rebuild repo' ' 183 rm -rf .git * && 184 git init && 185 git switch -c topic && 186 187 echo base >file && 188 git add file && 189 test_commit I && 190 191 echo A >file && 192 git add file && 193 test_commit A && 194 195 git switch -c branchB I && 196 echo B >file && 197 git add file && 198 test_commit B && 199 200 git switch topic && 201 test_must_fail git merge -m "M" B && 202 echo A >file && 203 echo B >>file && 204 git add file && 205 git merge --continue && 206 note M && 207 208 echo C >other && 209 git add other && 210 test_commit C && 211 212 git switch -c branchX I && 213 echo X >file && 214 git add file && 215 test_commit X && 216 217 git switch -c branchR M && 218 git merge -m R -Xtheirs X && 219 note R && 220 221 git switch topic && 222 git merge -m N R && 223 note N && 224 225 git switch -c branchY M && 226 echo Y >y && 227 git add y && 228 test_commit Y && 229 230 git switch -c branchZ C && 231 echo Z >z && 232 git add z && 233 test_commit Z && 234 235 git switch topic && 236 git merge -m O Z && 237 note O && 238 239 git merge -m P Y && 240 note P 241 ' 242 243 check_result 'X I' -- file 244 check_result 'N R X I' --show-pulls -- file 245 246 check_result 'P O N R X M B A I' --full-history --topo-order -- file 247 check_result 'N R X M B A I' --simplify-merges --topo-order --show-pulls -- file 248 check_result 'R X M B A I' --simplify-merges --topo-order -- file 249 check_result 'N M A I' --first-parent -- file 250 check_result 'N M A I' --first-parent --show-pulls -- file 251 252 # --ancestry-path implies --full-history 253 check_result 'P O N R M' --topo-order \ 254 --ancestry-path A..HEAD -- file 255 check_result 'P O N R M' --topo-order \ 256 --show-pulls \ 257 --ancestry-path A..HEAD -- file 258 check_result 'P O N R M' --topo-order \ 259 --full-history \ 260 --ancestry-path A..HEAD -- file 261 check_result 'R M' --topo-order \ 262 --simplify-merges \ 263 --ancestry-path A..HEAD -- file 264 check_result 'N R M' --topo-order \ 265 --simplify-merges --show-pulls \ 266 --ancestry-path A..HEAD -- file 267 268 test_expect_success 'log --graph --simplify-merges --show-pulls' ' 269 cat >expect <<-\EOF && 270 * N 271 * R 272 |\ 273 | * X 274 * | M 275 |\ \ 276 | * | B 277 | |/ 278 * / A 279 |/ 280 * I 281 EOF 282 git log --graph --pretty="%s" \ 283 --simplify-merges --show-pulls \ 284 -- file >actual && 285 test_cmp expect actual 286 ' 287 288 test_expect_success 'exclude-first-parent-only with parent already seen' ' 289 git checkout --orphan test-seen && 290 git rm -rf . && 291 test_commit r1 && 292 git checkout -b branch-f && 293 test_commit f && 294 git checkout test-seen && 295 git merge --no-ff --no-edit -m r2 branch-f && 296 git tag r2 && 297 298 git rev-list --exclude-first-parent-only f ^r2 >actual && 299 git rev-parse f >expect && 300 test_cmp expect actual && 301 302 git rev-list --exclude-first-parent-only f r1 ^r2 >actual2 && 303 test_cmp expect actual2 304 ' 305 306 test_done