-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·110 lines (96 loc) · 1.27 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
WD=$( mktemp -d -t git_test )
function cleanup {
rm -rf "$WD"
}
trap cleanup EXIT
cd "$WD"
git init
# Generate a history like this:
# A-----B---E---F
# \ / /
# `---C-´ /
# \ /
# `-D---´
cat > test <<EOT
a
b
c
d
e
f
g
EOT
git add test
git commit -m 'initial'
A=$(git rev-parse HEAD)
git branch i
cat > test <<EOT
a
bee
c
d
e
f
g
EOT
git add test
git commit -m 'bee'
B=$(git rev-parse HEAD)
git checkout -b d i
cat > test <<EOT
a
b
c
dee
e
f
g
EOT
git add test
git commit -m 'dee'
C=$(git rev-parse HEAD)
git checkout master
git merge --no-edit d
git branch -d d
E=$(git rev-parse HEAD)
git checkout -b f i
cat > test <<EOT
a
b
c
d
e
ef
g
EOT
git add test
git commit -m 'ef'
D=$(git rev-parse HEAD)
git checkout master
git merge --no-edit f
git branch -d f
F=$(git rev-parse HEAD)
git ll --all
FAILED=0
function test {
EXPECTED="$1"; shift
GOT="$( PATH="$DIR:$PATH" git merge-commit "$@" )"
if [ "$GOT" == "$EXPECTED" ]; then
echo "$@ -> $EXPECTED : OK"
else
echo "$@ -> $GOT : FAIL, expected $EXPECTED"
FAILED=$(( $FAILED + 1 ))
fi
}
# Test cases
test $A $A
test $B $A $B
test $E $A $B $C
test $E $B $C
test $E $B $C $E
test $F $B $D
if [ $FAILED -ne 0 ]; then
exit 1
fi