midx: implement `BTMP` chunk
[git/gitster.git] / t / t6009-rev-list-parent.sh
blobced40157ed68c077c17cb4758d1ebbc529e67d9c
1 #!/bin/sh
3 test_description='ancestor culling and limiting by parent number'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 check_revlist () {
12 rev_list_args="$1" &&
13 shift &&
14 git rev-parse "$@" >expect &&
15 git rev-list $rev_list_args --all >actual &&
16 test_cmp expect actual
19 test_expect_success setup '
21 touch file &&
22 git add file &&
24 test_commit one &&
26 test_tick=$(($test_tick - 2400)) &&
28 test_commit two &&
29 test_commit three &&
30 test_commit four &&
32 git log --pretty=oneline --abbrev-commit
35 test_expect_success 'one is ancestor of others and should not be shown' '
37 git rev-list one --not four >result &&
38 test_must_be_empty result
42 test_expect_success 'setup roots, merges and octopuses' '
44 git checkout --orphan newroot &&
45 test_commit five &&
46 git checkout -b sidebranch two &&
47 test_commit six &&
48 git checkout -b anotherbranch three &&
49 test_commit seven &&
50 git checkout -b yetanotherbranch four &&
51 test_commit eight &&
52 git checkout main &&
53 test_tick &&
54 git merge --allow-unrelated-histories -m normalmerge newroot &&
55 git tag normalmerge &&
56 test_tick &&
57 git merge -m tripus sidebranch anotherbranch &&
58 git tag tripus &&
59 git checkout -b tetrabranch normalmerge &&
60 test_tick &&
61 git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
62 git tag tetrapus &&
63 git checkout main
66 test_expect_success 'rev-list roots' '
68 check_revlist "--max-parents=0" one five
71 test_expect_success 'rev-list no merges' '
73 check_revlist "--max-parents=1" one eight seven six five four three two &&
74 check_revlist "--no-merges" one eight seven six five four three two
77 test_expect_success 'rev-list no octopuses' '
79 check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
82 test_expect_success 'rev-list no roots' '
84 check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
87 test_expect_success 'rev-list merges' '
89 check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
90 check_revlist "--merges" tetrapus tripus normalmerge
93 test_expect_success 'rev-list octopus' '
95 check_revlist "--min-parents=3" tetrapus tripus
98 test_expect_success 'rev-list ordinary commits' '
100 check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
103 test_expect_success 'rev-list --merges --no-merges yields empty set' '
105 check_revlist "--min-parents=2 --no-merges" &&
106 check_revlist "--merges --no-merges" &&
107 check_revlist "--no-merges --merges"
110 test_expect_success 'rev-list override and infinities' '
112 check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
113 check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
114 check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
115 check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
116 check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
117 check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
120 test_expect_success 'dodecapus' '
122 roots= &&
123 for i in 1 2 3 4 5 6 7 8 9 10 11
125 git checkout -b root$i five &&
126 test_commit $i &&
127 roots="$roots root$i" ||
128 return 1
129 done &&
130 git checkout main &&
131 test_tick &&
132 git merge -m dodecapus $roots &&
133 git tag dodecapus &&
135 check_revlist "--min-parents=4" dodecapus tetrapus &&
136 check_revlist "--min-parents=8" dodecapus &&
137 check_revlist "--min-parents=12" dodecapus &&
138 check_revlist "--min-parents=13" &&
139 check_revlist "--min-parents=4 --max-parents=11" tetrapus
142 test_expect_success 'ancestors with the same commit time' '
144 test_tick_keep=$test_tick &&
145 for i in 1 2 3 4 5 6 7 8; do
146 test_tick=$test_tick_keep &&
147 test_commit t$i || return 1
148 done &&
149 git rev-list t1^! --not t$i >result &&
150 test_must_be_empty result
153 test_done