@matheusbsbs / matheus-bagliano / commits / a7a6692177
Fork 0

merge-base-many: add trivial tests based on the documentation

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 29, 2008 at 23:51 UTC a7a66921772ca5e609d283b0b73b8dd446a2a506
1 file changed +48
t/t6010-merge-base.sh
+48
@@ -108,4 +108,52 @@ 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"'
110
111 +# Another set to demonstrate base between one commit and a merge
112 +# in the documentation.
113 +
114 +test_expect_success 'merge-base for octopus-step (setup)' '
115 + test_tick && git commit --allow-empty -m root && git tag MMR &&
116 + test_tick && git commit --allow-empty -m 1 && git tag MM1 &&
117 + test_tick && git commit --allow-empty -m o &&
118 + test_tick && git commit --allow-empty -m o &&
119 + test_tick && git commit --allow-empty -m o &&
120 + test_tick && git commit --allow-empty -m A && git tag MMA &&
121 + git checkout MM1 &&
122 + test_tick && git commit --allow-empty -m o &&
123 + test_tick && git commit --allow-empty -m o &&
124 + test_tick && git commit --allow-empty -m o &&
125 + test_tick && git commit --allow-empty -m B && git tag MMB &&
126 + git checkout MMR &&
127 + test_tick && git commit --allow-empty -m o &&
128 + test_tick && git commit --allow-empty -m o &&
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 C && git tag MMC
132 +'
133 +
134 +test_expect_success 'merge-base A B C' '
135 + MB=$(git merge-base --all MMA MMB MMC) &&
136 + MM1=$(git rev-parse --verify MM1) &&
137 + test "$MM1" = "$MB"
138 +'
139 +
140 +test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
141 + git reset --hard MMR &&
142 + test_tick && git commit --allow-empty -m 1 && git tag CC1 &&
143 + git reset --hard E &&
144 + test_tick && git commit --allow-empty -m 2 && git tag CC2 &&
145 + test_tick && git merge -s ours CC1 &&
146 + test_tick && git commit --allow-empty -m o &&
147 + test_tick && git commit --allow-empty -m B && git tag CCB &&
148 + git reset --hard CC1 &&
149 + test_tick && git merge -s ours CC2 &&
150 + test_tick && git commit --allow-empty -m A && git tag CCA
151 +'
152 +
153 +test_expect_success 'merge-base B A^^ A^^2' '
154 + MB0=$(git merge-base --all CCB CCA^^ CCA^^2 | sort) &&
155 + MB1=$(git rev-parse CC1 CC2 | sort) &&
156 + test "$MB0" = "$MB1"
157 +'
158 +
159 test_done