]>
Commit | Line | Data |
---|---|---|
53de71f8 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Merge base computation. | |
7 | ' | |
8 | ||
9 | . ./test-lib.sh | |
10 | ||
11 | T=$(git-write-tree) | |
12 | ||
13 | M=1130000000 | |
14 | Z=+0000 | |
15 | ||
16 | export GIT_COMMITTER_EMAIL=git@comm.iter.xz | |
17 | export GIT_COMMITTER_NAME='C O Mmiter' | |
18 | export GIT_AUTHOR_NAME='A U Thor' | |
19 | export GIT_AUTHOR_EMAIL=git@au.thor.xz | |
20 | ||
21 | doit() { | |
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... | |
38 | E=$(doit 5 E) | |
39 | D=$(doit 4 D $E) | |
40 | F=$(doit 6 F $E) | |
41 | C=$(doit 3 C $D) | |
42 | B=$(doit 2 B $C) | |
43 | A=$(doit 1 A $B) | |
44 | G=$(doit 7 G $B $E) | |
45 | H=$(doit 8 H $A $F) | |
46 | ||
cd6f207a LAS |
47 | # Setup for second test to demonstrate that relying on timestamps in a |
48 | # distributed SCM to provide a _consistent_ partial ordering of commits | |
49 | # leads to insanity. | |
50 | # | |
51 | # Relative | |
52 | # Structure timestamps | |
53 | # | |
54 | # PL PR +4 +4 | |
55 | # / \/ \ / \/ \ | |
56 | # L2 C2 R2 +3 -1 +3 | |
57 | # | | | | | | | |
58 | # L1 C1 R1 +2 -2 +2 | |
59 | # | | | | | | | |
60 | # L0 C0 R0 +1 -3 +1 | |
61 | # \ | / \ | / | |
62 | # S 0 | |
63 | # | |
64 | # The left and right chains of commits can be of any length and complexity as | |
65 | # long as all of the timestamps are greater than that of S. | |
66 | ||
67 | S=$(doit 0 S) | |
68 | ||
69 | C0=$(doit -3 C0 $S) | |
70 | C1=$(doit -2 C1 $C0) | |
71 | C2=$(doit -1 C2 $C1) | |
72 | ||
73 | L0=$(doit 1 L0 $S) | |
74 | L1=$(doit 2 L1 $L0) | |
75 | L2=$(doit 3 L2 $L1) | |
76 | ||
77 | R0=$(doit 1 R0 $S) | |
78 | R1=$(doit 2 R1 $R0) | |
79 | R2=$(doit 3 R2 $R1) | |
80 | ||
81 | PL=$(doit 4 PL $L2 $C2) | |
82 | PR=$(doit 4 PR $C2 $R2) | |
83 | ||
53de71f8 JH |
84 | test_expect_success 'compute merge-base (single)' \ |
85 | 'MB=$(git-merge-base G H) && | |
2c817df2 | 86 | expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' |
53de71f8 JH |
87 | |
88 | test_expect_success 'compute merge-base (all)' \ | |
89 | 'MB=$(git-merge-base --all G H) && | |
2c817df2 | 90 | expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' |
53de71f8 JH |
91 | |
92 | test_expect_success 'compute merge-base with show-branch' \ | |
93 | 'MB=$(git-show-branch --merge-base G H) && | |
2c817df2 | 94 | expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' |
53de71f8 | 95 | |
cd6f207a LAS |
96 | test_expect_success 'compute merge-base (single)' \ |
97 | 'MB=$(git-merge-base PL PR) && | |
98 | expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/C2"' | |
99 | ||
100 | test_expect_success 'compute merge-base (all)' \ | |
101 | 'MB=$(git-merge-base --all PL PR) && | |
102 | expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/C2"' | |
103 | ||
53de71f8 | 104 | test_done |