]>
Commit | Line | Data |
---|---|---|
991c3dc7 JH |
1 | #!/bin/sh |
2 | ||
6a6ebded | 3 | test_description='ancestor culling and limiting by parent number' |
991c3dc7 JH |
4 | |
5 | . ./test-lib.sh | |
6 | ||
6a6ebded MG |
7 | check_revlist () { |
8 | rev_list_args="$1" && | |
9 | shift && | |
10 | git rev-parse "$@" >expect && | |
11 | git rev-list $rev_list_args --all >actual && | |
12 | test_cmp expect actual | |
13 | } | |
14 | ||
991c3dc7 JH |
15 | test_expect_success setup ' |
16 | ||
17 | touch file && | |
18 | git add file && | |
19 | ||
8ee50594 | 20 | test_commit one && |
991c3dc7 | 21 | |
a48fcd83 | 22 | test_tick=$(($test_tick - 2400)) && |
991c3dc7 | 23 | |
8ee50594 MG |
24 | test_commit two && |
25 | test_commit three && | |
26 | test_commit four && | |
991c3dc7 JH |
27 | |
28 | git log --pretty=oneline --abbrev-commit | |
29 | ' | |
30 | ||
7d004199 | 31 | test_expect_success 'one is ancestor of others and should not be shown' ' |
991c3dc7 JH |
32 | |
33 | git rev-list one --not four >result && | |
34 | >expect && | |
82ebb0b6 | 35 | test_cmp expect result |
991c3dc7 JH |
36 | |
37 | ' | |
38 | ||
6a6ebded MG |
39 | test_expect_success 'setup roots, merges and octopuses' ' |
40 | ||
41 | git checkout --orphan newroot && | |
42 | test_commit five && | |
43 | git checkout -b sidebranch two && | |
44 | test_commit six && | |
45 | git checkout -b anotherbranch three && | |
46 | test_commit seven && | |
47 | git checkout -b yetanotherbranch four && | |
48 | test_commit eight && | |
49 | git checkout master && | |
e379fdf3 JH |
50 | test_tick && |
51 | git merge --allow-unrelated-histories -m normalmerge newroot && | |
52 | git tag normalmerge && | |
6a6ebded MG |
53 | test_tick && |
54 | git merge -m tripus sidebranch anotherbranch && | |
55 | git tag tripus && | |
56 | git checkout -b tetrabranch normalmerge && | |
57 | test_tick && | |
58 | git merge -m tetrapus sidebranch anotherbranch yetanotherbranch && | |
59 | git tag tetrapus && | |
60 | git checkout master | |
61 | ' | |
62 | ||
63 | test_expect_success 'rev-list roots' ' | |
64 | ||
65 | check_revlist "--max-parents=0" one five | |
66 | ' | |
67 | ||
68 | test_expect_success 'rev-list no merges' ' | |
69 | ||
70 | check_revlist "--max-parents=1" one eight seven six five four three two && | |
71 | check_revlist "--no-merges" one eight seven six five four three two | |
72 | ' | |
73 | ||
74 | test_expect_success 'rev-list no octopuses' ' | |
75 | ||
76 | check_revlist "--max-parents=2" one normalmerge eight seven six five four three two | |
77 | ' | |
78 | ||
79 | test_expect_success 'rev-list no roots' ' | |
80 | ||
81 | check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two | |
82 | ' | |
83 | ||
84 | test_expect_success 'rev-list merges' ' | |
85 | ||
86 | check_revlist "--min-parents=2" tetrapus tripus normalmerge && | |
87 | check_revlist "--merges" tetrapus tripus normalmerge | |
88 | ' | |
89 | ||
90 | test_expect_success 'rev-list octopus' ' | |
91 | ||
92 | check_revlist "--min-parents=3" tetrapus tripus | |
93 | ' | |
94 | ||
95 | test_expect_success 'rev-list ordinary commits' ' | |
96 | ||
97 | check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two | |
98 | ' | |
99 | ||
100 | test_expect_success 'rev-list --merges --no-merges yields empty set' ' | |
101 | ||
102 | check_revlist "--min-parents=2 --no-merges" && | |
103 | check_revlist "--merges --no-merges" && | |
104 | check_revlist "--no-merges --merges" | |
105 | ' | |
106 | ||
107 | test_expect_success 'rev-list override and infinities' ' | |
108 | ||
109 | check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge && | |
110 | check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge && | |
111 | check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge && | |
112 | check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge && | |
113 | check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge && | |
114 | check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five | |
115 | ' | |
116 | ||
482ce70e | 117 | test_expect_success 'dodecapus' ' |
6a6ebded | 118 | |
482ce70e | 119 | roots= && |
6a6ebded MG |
120 | for i in 1 2 3 4 5 6 7 8 9 10 11 |
121 | do | |
482ce70e JN |
122 | git checkout -b root$i five && |
123 | test_commit $i && | |
124 | roots="$roots root$i" || | |
125 | return | |
6a6ebded MG |
126 | done && |
127 | git checkout master && | |
128 | test_tick && | |
482ce70e JN |
129 | git merge -m dodecapus $roots && |
130 | git tag dodecapus && | |
6a6ebded MG |
131 | |
132 | check_revlist "--min-parents=4" dodecapus tetrapus && | |
133 | check_revlist "--min-parents=8" dodecapus && | |
134 | check_revlist "--min-parents=12" dodecapus && | |
135 | check_revlist "--min-parents=13" && | |
136 | check_revlist "--min-parents=4 --max-parents=11" tetrapus | |
137 | ' | |
c19d1b4e KK |
138 | |
139 | test_expect_success 'ancestors with the same commit time' ' | |
140 | ||
141 | test_tick_keep=$test_tick && | |
142 | for i in 1 2 3 4 5 6 7 8; do | |
143 | test_tick=$test_tick_keep | |
144 | test_commit t$i | |
145 | done && | |
146 | git rev-list t1^! --not t$i >result && | |
147 | >expect && | |
148 | test_cmp expect result | |
149 | ' | |
150 | ||
991c3dc7 | 151 | test_done |