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
14 git rev-parse
"$@" >expect
&&
15 git rev-list
$rev_list_args --all >actual
&&
16 test_cmp expect actual
19 test_expect_success setup
'
26 test_tick=$(($test_tick - 2400)) &&
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 &&
46 git checkout -b sidebranch two &&
48 git checkout -b anotherbranch three &&
50 git checkout -b yetanotherbranch four &&
54 git merge --allow-unrelated-histories -m normalmerge newroot &&
55 git tag normalmerge &&
57 git merge -m tripus sidebranch anotherbranch &&
59 git checkout -b tetrabranch normalmerge &&
61 git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
66 test_expect_success
'parse --max-parents & --min-parents' '
67 test_must_fail git rev-list --max-parents=1q HEAD 2>error &&
68 grep "not an integer" error &&
70 test_must_fail git rev-list --min-parents=1q HEAD 2>error &&
71 grep "not an integer" error &&
73 git rev-list --max-parents=1 --min-parents=1 HEAD &&
74 git rev-list --max-parents=-1 --min-parents=-1 HEAD
77 test_expect_success
'rev-list roots' '
79 check_revlist "--max-parents=0" one five
82 test_expect_success
'rev-list no merges' '
84 check_revlist "--max-parents=1" one eight seven six five four three two &&
85 check_revlist "--no-merges" one eight seven six five four three two
88 test_expect_success
'rev-list no octopuses' '
90 check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
93 test_expect_success
'rev-list no roots' '
95 check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
98 test_expect_success
'rev-list merges' '
100 check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
101 check_revlist "--merges" tetrapus tripus normalmerge
104 test_expect_success
'rev-list octopus' '
106 check_revlist "--min-parents=3" tetrapus tripus
109 test_expect_success
'rev-list ordinary commits' '
111 check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
114 test_expect_success
'rev-list --merges --no-merges yields empty set' '
116 check_revlist "--min-parents=2 --no-merges" &&
117 check_revlist "--merges --no-merges" &&
118 check_revlist "--no-merges --merges"
121 test_expect_success
'rev-list override and infinities' '
123 check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
124 check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
125 check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
126 check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
127 check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
128 check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
131 test_expect_success
'dodecapus' '
134 for i in 1 2 3 4 5 6 7 8 9 10 11
136 git checkout -b root$i five &&
138 roots="$roots root$i" ||
143 git merge -m dodecapus $roots &&
146 check_revlist "--min-parents=4" dodecapus tetrapus &&
147 check_revlist "--min-parents=8" dodecapus &&
148 check_revlist "--min-parents=12" dodecapus &&
149 check_revlist "--min-parents=13" &&
150 check_revlist "--min-parents=4 --max-parents=11" tetrapus
153 test_expect_success
'ancestors with the same commit time' '
155 test_tick_keep=$test_tick &&
156 for i in 1 2 3 4 5 6 7 8; do
157 test_tick=$test_tick_keep &&
158 test_commit t$i || return 1
160 git rev-list t1^! --not t$i >result &&
161 test_must_be_empty result