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
13 git rev-parse
"$@" >expect
&&
14 git rev-list
$rev_list_args --all >actual
&&
15 test_cmp expect actual
18 test_expect_success setup
'
25 test_tick=$(($test_tick - 2400)) &&
31 git log --pretty=oneline --abbrev-commit
34 test_expect_success
'one is ancestor of others and should not be shown' '
36 git rev-list one --not four >result &&
37 test_must_be_empty result
41 test_expect_success
'setup roots, merges and octopuses' '
43 git checkout --orphan newroot &&
45 git checkout -b sidebranch two &&
47 git checkout -b anotherbranch three &&
49 git checkout -b yetanotherbranch four &&
53 git merge --allow-unrelated-histories -m normalmerge newroot &&
54 git tag normalmerge &&
56 git merge -m tripus sidebranch anotherbranch &&
58 git checkout -b tetrabranch normalmerge &&
60 git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
65 test_expect_success
'rev-list roots' '
67 check_revlist "--max-parents=0" one five
70 test_expect_success
'rev-list no merges' '
72 check_revlist "--max-parents=1" one eight seven six five four three two &&
73 check_revlist "--no-merges" one eight seven six five four three two
76 test_expect_success
'rev-list no octopuses' '
78 check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
81 test_expect_success
'rev-list no roots' '
83 check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
86 test_expect_success
'rev-list merges' '
88 check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
89 check_revlist "--merges" tetrapus tripus normalmerge
92 test_expect_success
'rev-list octopus' '
94 check_revlist "--min-parents=3" tetrapus tripus
97 test_expect_success
'rev-list ordinary commits' '
99 check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
102 test_expect_success
'rev-list --merges --no-merges yields empty set' '
104 check_revlist "--min-parents=2 --no-merges" &&
105 check_revlist "--merges --no-merges" &&
106 check_revlist "--no-merges --merges"
109 test_expect_success
'rev-list override and infinities' '
111 check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
112 check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
113 check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
114 check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
115 check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
116 check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
119 test_expect_success
'dodecapus' '
122 for i in 1 2 3 4 5 6 7 8 9 10 11
124 git checkout -b root$i five &&
126 roots="$roots root$i" ||
131 git merge -m dodecapus $roots &&
134 check_revlist "--min-parents=4" dodecapus tetrapus &&
135 check_revlist "--min-parents=8" dodecapus &&
136 check_revlist "--min-parents=12" dodecapus &&
137 check_revlist "--min-parents=13" &&
138 check_revlist "--min-parents=4 --max-parents=11" tetrapus
141 test_expect_success
'ancestors with the same commit time' '
143 test_tick_keep=$test_tick &&
144 for i in 1 2 3 4 5 6 7 8; do
145 test_tick=$test_tick_keep
148 git rev-list t1^! --not t$i >result &&
149 test_must_be_empty result