1#!/bin/sh
23
test_description='merge simplification'
45
. ./test-lib.sh
67
note () {
8git tag "$1"
9}
1011
unnote () {
12git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
13}
1415
test_expect_success setup '
16echo "Hi there" >file &&
17git add file &&
18test_tick && git commit -m "Initial file" &&
19note A &&
2021
git branch other-branch &&
2223
echo "Hello" >file &&
24git add file &&
25test_tick && git commit -m "Modified file" &&
26note B &&
2728
git checkout other-branch &&
2930
echo "Hello" >file &&
31git add file &&
32test_tick && git commit -m "Modified the file identically" &&
33note C &&
3435
echo "This is a stupid example" >another-file &&
36git add another-file &&
37test_tick && git commit -m "Add another file" &&
38note D &&
3940
test_tick && git merge -m "merge" master &&
41note E &&
4243
echo "Yet another" >elif &&
44git add elif &&
45test_tick && git commit -m "Irrelevant change" &&
46note F &&
4748
git checkout master &&
49echo "Yet another" >elif &&
50git add elif &&
51test_tick && git commit -m "Another irrelevant change" &&
52note G &&
5354
test_tick && git merge -m "merge" other-branch &&
55note H &&
5657
echo "Final change" >file &&
58test_tick && git commit -a -m "Final change" &&
59note I &&
6061
git symbolic-ref HEAD refs/heads/unrelated &&
62git rm -f "*" &&
63echo "Unrelated branch" >side &&
64git add side &&
65test_tick && git commit -m "Side root" &&
66note J &&
6768
git checkout master &&
69test_tick && git merge -m "Coolest" unrelated &&
70note K &&
7172
echo "Immaterial" >elif &&
73git add elif &&
74test_tick && git commit -m "Last" &&
75note L
76'
7778
FMT='tformat:%P %H | %s'
7980
check_result () {
81for c in $1
82do
83echo "$c"
84done >expect &&
85shift &&
86param="$*" &&
87test_expect_success "log $param" '
88git log --pretty="$FMT" --parents $param |
89unnote >actual &&
90sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
91test_cmp expect check || {
92cat actual
93false
94}
95'
96}
9798
check_result 'L K J I H G F E D C B A' --full-history
99check_result 'K I H E C B A' --full-history -- file
100check_result 'K I H E C B A' --full-history --topo-order -- file
101check_result 'K I H E C B A' --full-history --date-order -- file
102check_result 'I E C B A' --simplify-merges -- file
103check_result 'I B A' -- file
104check_result 'I B A' --topo-order -- file
105check_result 'H' --first-parent -- another-file
106107
test_done