3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Merge base computation.
16 GIT_COMMITTER_EMAIL=git@comm.iter.xz
17 GIT_COMMITTER_NAME='C O Mmiter'
18 GIT_AUTHOR_NAME='A U Thor'
19 GIT_AUTHOR_EMAIL=git@au.thor.xz
20 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
28 PARENTS="${PARENTS}-p $P "
30 GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z"
31 GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE
32 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
33 commit=$(echo $NAME | git commit-tree $T $PARENTS)
34 echo $commit >.git/refs/tags/$NAME
54 test_expect_success 'compute merge-base (single)' \
55 'MB=$(git merge-base G H) &&
56 expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
58 test_expect_success 'compute merge-base (all)' \
59 'MB=$(git merge-base --all G H) &&
60 expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
62 test_expect_success 'compute merge-base with show-branch' \
63 'MB=$(git show-branch --merge-base G H) &&
64 expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
66 # Setup for second test to demonstrate that relying on timestamps in a
67 # distributed SCM to provide a _consistent_ partial ordering of commits
71 # Structure timestamps
83 # The left and right chains of commits can be of any length and complexity as
84 # long as all of the timestamps are greater than that of S.
100 PL=$(doit 4 PL $L2 $C2)
101 PR=$(doit 4 PR $C2 $R2)
103 test_expect_success 'compute merge-base (single)' \
104 'MB=$(git merge-base PL PR) &&
105 expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"'
107 test_expect_success 'compute merge-base (all)' \
108 'MB=$(git merge-base --all PL PR) &&
109 expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"'
111 # Another set to demonstrate base between one commit and a merge
112 # in the documentation.
114 # * C (MMC) * B (MMB) * A (MMA)
126 test_expect_success 'merge-base for octopus-step (setup)' '
127 test_tick && git commit --allow-empty -m root && git tag MMR &&
128 test_tick && git commit --allow-empty -m 1 && git tag MM1 &&
129 test_tick && git commit --allow-empty -m o &&
130 test_tick && git commit --allow-empty -m o &&
131 test_tick && git commit --allow-empty -m o &&
132 test_tick && git commit --allow-empty -m A && git tag MMA &&
134 test_tick && git commit --allow-empty -m o &&
135 test_tick && git commit --allow-empty -m o &&
136 test_tick && git commit --allow-empty -m o &&
137 test_tick && git commit --allow-empty -m B && git tag MMB &&
139 test_tick && git commit --allow-empty -m o &&
140 test_tick && git commit --allow-empty -m o &&
141 test_tick && git commit --allow-empty -m o &&
142 test_tick && git commit --allow-empty -m o &&
143 test_tick && git commit --allow-empty -m C && git tag MMC
146 test_expect_success 'merge-base A B C' '
147 MB=$(git merge-base --all MMA MMB MMC) &&
148 MM1=$(git rev-parse --verify MM1) &&
152 test_expect_success 'merge-base A B C using show-branch' '
153 MB=$(git show-branch --merge-base MMA MMB MMC) &&
154 MMR=$(git rev-parse --verify MMR) &&
158 test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
159 git reset --hard MMR &&
160 test_tick && git commit --allow-empty -m 1 && git tag CC1 &&
161 git reset --hard E &&
162 test_tick && git commit --allow-empty -m 2 && git tag CC2 &&
163 test_tick && git merge -s ours CC1 &&
164 test_tick && git commit --allow-empty -m o &&
165 test_tick && git commit --allow-empty -m B && git tag CCB &&
166 git reset --hard CC1 &&
167 test_tick && git merge -s ours CC2 &&
168 test_tick && git commit --allow-empty -m A && git tag CCA
171 test_expect_success 'merge-base B A^^ A^^2' '
172 MB0=$(git merge-base --all CCB CCA^^ CCA^^2 | sort) &&
173 MB1=$(git rev-parse CC1 CC2 | sort) &&