1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Merge base computation.
7'
8
9. ./test-lib.sh
10
11T=$(git-write-tree)
12
13M=1130000000
14Z=+0000
15
16export GIT_COMMITTER_EMAIL=git@comm.iter.xz
17export GIT_COMMITTER_NAME='C O Mmiter'
18export GIT_AUTHOR_NAME='A U Thor'
19export GIT_AUTHOR_EMAIL=git@au.thor.xz
20
21doit() {
22 OFFSET=$1; shift
23 NAME=$1; shift
24 PARENTS=
25 for P
26 do
27 PARENTS="${PARENTS}-p $P "
28 done
29 GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z"
30 GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE
31 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
32 commit=$(echo $NAME | git-commit-tree $T $PARENTS)
33 echo $commit >.git/refs/tags/$NAME
34 echo $commit
35}
36
37# Setup...
38E=$(doit 5 E)
39D=$(doit 4 D $E)
40F=$(doit 6 F $E)
41C=$(doit 3 C $D)
42B=$(doit 2 B $C)
43A=$(doit 1 A $B)
44G=$(doit 7 G $B $E)
45H=$(doit 8 H $A $F)
46
47test_expect_success 'compute merge-base (single)' \
48 'MB=$(git-merge-base G H) &&
49 expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
50
51test_expect_success 'compute merge-base (all)' \
52 'MB=$(git-merge-base --all G H) &&
53 expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
54
55test_expect_success 'compute merge-base with show-branch' \
56 'MB=$(git-show-branch --merge-base G H) &&
57 expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
58
59test_done