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
60'
6162
FMT='tformat:%P %H | %s'
6364
check_result () {
65for c in $1
66do
67echo "$c"
68done >expect &&
69shift &&
70param="$*" &&
71test_expect_success "log $param" '
72git log --pretty="$FMT" --parents $param |
73unnote >actual &&
74sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
75test_cmp expect check || {
76cat actual
77false
78}
79'
80}
8182
check_result 'I H G F E D C B A' --full-history
83check_result 'I H E C B A' --full-history -- file
84check_result 'I H E C B A' --full-history --topo-order -- file
85check_result 'I H E C B A' --full-history --date-order -- file
86check_result 'I E C B A' --simplify-merges -- file
87check_result 'I B A' -- file
88check_result 'I B A' --topo-order -- file
89check_result 'H' --first-parent -- another-file
9091
test_done