Skip to content

Commit a6b4db3

Browse files
committed
add remaining baseline tests along with permutations
1 parent e97f90b commit a6b4db3

File tree

2 files changed

+154
-11
lines changed

2 files changed

+154
-11
lines changed
Binary file not shown.

gix-revision/tests/fixtures/make_merge_base_repos.sh

Lines changed: 154 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eu -o pipefail
44
git init
55

66
EMPTY_TREE=$(git mktree </dev/null)
7-
function mkcommit () {
7+
function ofs_commit () {
88
local OFFSET_SECONDS=$1
99
local COMMIT_NAME=$2
1010
shift 2
@@ -33,8 +33,8 @@ function baseline() {
3333

3434
# Merge-bases adapted from Git test suite
3535
# No merge base
36-
mkcommit 0 DA
37-
mkcommit 100 DB
36+
ofs_commit 0 DA
37+
ofs_commit 100 DB
3838
{
3939
echo "just-one-returns-one-in-code"
4040
echo $(git rev-parse DA)
@@ -52,19 +52,20 @@ mkcommit 100 DB
5252
# \ `---------G \
5353
# \ \
5454
# F----------------H
55-
E=$(mkcommit 5 E)
56-
D=$(mkcommit 4 D $E)
57-
F=$(mkcommit 6 F $E)
58-
C=$(mkcommit 3 C $D)
59-
B=$(mkcommit 2 B $C)
60-
A=$(mkcommit 1 A $B)
61-
G=$(mkcommit 7 G $B $E)
62-
H=$(mkcommit 8 H $A $F)
55+
E=$(ofs_commit 5 E)
56+
D=$(ofs_commit 4 D $E)
57+
F=$(ofs_commit 6 F $E)
58+
C=$(ofs_commit 3 C $D)
59+
B=$(ofs_commit 2 B $C)
60+
A=$(ofs_commit 1 A $B)
61+
G=$(ofs_commit 7 G $B $E)
62+
H=$(ofs_commit 8 H $A $F)
6363

6464
{
6565
baseline G H
6666
} > 2_a.baseline
6767

68+
# Permutation testing - let's do it early to avoid too many permutations
6869
commits=$(git log --all --format=%s)
6970
commit_array=($commits)
7071
num_commits=${#commit_array[@]}
@@ -75,5 +76,147 @@ for ((i=0; i<num_commits; i++)); do
7576
done
7677
done > 3_permutations.baseline
7778

79+
# Timestamps cannot be trusted.
80+
#
81+
# Relative
82+
# Structure timestamps
83+
#
84+
# PL PR +4 +4
85+
# / \/ \ / \/ \
86+
# L2 C2 R2 +3 -1 +3
87+
# | | | | | |
88+
# L1 C1 R1 +2 -2 +2
89+
# | | | | | |
90+
# L0 C0 R0 +1 -3 +1
91+
# \ | / \ | /
92+
# S 0
93+
#
94+
# The left and right chains of commits can be of any length and complexity as
95+
# long as all of the timestamps are greater than that of S.
96+
S=$(ofs_commit 0 S)
97+
98+
C0=$(ofs_commit -3 C0 $S)
99+
C1=$(ofs_commit -2 C1 $C0)
100+
C2=$(ofs_commit -1 C2 $C1)
101+
102+
L0=$(ofs_commit 1 L0 $S)
103+
L1=$(ofs_commit 2 L1 $L0)
104+
L2=$(ofs_commit 3 L2 $L1)
105+
106+
R0=$(ofs_commit 1 R0 $S)
107+
R1=$(ofs_commit 2 R1 $R0)
108+
R2=$(ofs_commit 3 R2 $R1)
109+
110+
PL=$(ofs_commit 4 PL $L2 $C2)
111+
PR=$(ofs_commit 4 PR $C2 $R2)
112+
113+
{
114+
baseline PL PR
115+
} > 4_b.baseline
116+
117+
118+
function tick () {
119+
if test -z "${tick+set}"
120+
then
121+
tick=1112911993
122+
else
123+
tick=$(($tick + 60))
124+
fi
125+
GIT_COMMITTER_DATE="$tick -0700"
126+
GIT_AUTHOR_DATE="$tick -0700"
127+
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
128+
}
129+
130+
tick
131+
function commit() {
132+
local message=${1:?first argument is the commit message}
133+
local date=${2:-}
134+
if [ -n "$date" ]; then
135+
export GIT_COMMITTER_DATE="$date"
136+
else
137+
tick
138+
fi
139+
git commit --allow-empty -m "$message"
140+
git tag "$message"
141+
}
142+
143+
# * C (MMC) * B (MMB) * A (MMA)
144+
# * o * o * o
145+
# * o * o * o
146+
# * o * o * o
147+
# * o | _______/
148+
# | |/
149+
# | * 1 (MM1)
150+
# | _______/
151+
# |/
152+
# * root (MMR)
153+
154+
commit MMR
155+
commit MM1
156+
commit MM-o
157+
commit MM-p
158+
commit MM-q
159+
commit MMA
160+
git checkout MM1
161+
commit MM-r
162+
commit MM-s
163+
commit MM-t
164+
commit MMB
165+
git checkout MMR
166+
commit MM-u
167+
commit MM-v
168+
commit MM-w
169+
commit MM-x
170+
commit MMC
171+
172+
{
173+
baseline MMA MMB MMC
174+
} > 5_c.baseline
175+
176+
merge () {
177+
label="$1"
178+
shift
179+
tick
180+
git merge -m "$label" "$@"
181+
git tag "$label"
182+
}
183+
184+
# JE
185+
# / |
186+
# / |
187+
# / |
188+
# JAA / |
189+
# |\ / |
190+
# | \ | JDD |
191+
# | \ |/ | |
192+
# | JC JD |
193+
# | | /| |
194+
# | |/ | |
195+
# JA | | |
196+
# |\ /| | |
197+
# X JB | X X
198+
# \ \ | / /
199+
# \__\|/___/
200+
# J
201+
commit J
202+
commit JB
203+
git reset --hard J
204+
commit JC
205+
git reset --hard J
206+
commit JTEMP1
207+
merge JA JB
208+
merge JAA JC
209+
git reset --hard J
210+
commit JTEMP2
211+
merge JD JB
212+
merge JDD JC
213+
git reset --hard J
214+
commit JTEMP3
215+
merge JE JC
216+
217+
{
218+
baseline JAA JDD JE
219+
} > 5_c.baseline
220+
78221
git commit-graph write --no-progress --reachable
79222
git repack -adq

0 commit comments

Comments
 (0)