]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6012-rev-list-simplify.sh
simplify-merges: drop merge from irrelevant side branch
[thirdparty/git.git] / t / t6012-rev-list-simplify.sh
CommitLineData
65347030
JH
1#!/bin/sh
2
3test_description='merge simplification'
4
5. ./test-lib.sh
6
7note () {
8 git tag "$1"
9}
10
11_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
12_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
13
14unnote () {
15 git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
16}
17
18test_expect_success setup '
19 echo "Hi there" >file &&
20 git add file &&
21 test_tick && git commit -m "Initial file" &&
22 note A &&
23
24 git branch other-branch &&
25
26 echo "Hello" >file &&
27 git add file &&
28 test_tick && git commit -m "Modified file" &&
29 note B &&
30
31 git checkout other-branch &&
32
33 echo "Hello" >file &&
34 git add file &&
35 test_tick && git commit -m "Modified the file identically" &&
36 note C &&
37
38 echo "This is a stupid example" >another-file &&
39 git add another-file &&
40 test_tick && git commit -m "Add another file" &&
41 note D &&
42
43 test_tick && git merge -m "merge" master &&
44 note E &&
45
46 echo "Yet another" >elif &&
47 git add elif &&
48 test_tick && git commit -m "Irrelevant change" &&
49 note F &&
50
51 git checkout master &&
52 echo "Yet another" >elif &&
53 git add elif &&
54 test_tick && git commit -m "Another irrelevant change" &&
55 note G &&
56
57 test_tick && git merge -m "merge" other-branch &&
58 note H &&
59
60 echo "Final change" >file &&
61 test_tick && git commit -a -m "Final change" &&
4b7f53da
JH
62 note I &&
63
64 git symbolic-ref HEAD refs/heads/unrelated &&
65 git rm -f "*" &&
66 echo "Unrelated branch" >side &&
67 git add side &&
68 test_tick && git commit -m "Side root" &&
69 note J &&
70
71 git checkout master &&
72 test_tick && git merge -m "Coolest" unrelated &&
73 note K &&
74
75 echo "Immaterial" >elif &&
76 git add elif &&
77 test_tick && git commit -m "Last" &&
78 note L
65347030
JH
79'
80
81FMT='tformat:%P %H | %s'
82
83check_result () {
84 for c in $1
85 do
86 echo "$c"
87 done >expect &&
88 shift &&
89 param="$*" &&
90 test_expect_success "log $param" '
91 git log --pretty="$FMT" --parents $param |
92 unnote >actual &&
93 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
94 test_cmp expect check || {
95 cat actual
96 false
97 }
98 '
99}
100
4b7f53da
JH
101check_result 'L K J I H G F E D C B A' --full-history
102check_result 'K I H E C B A' --full-history -- file
103check_result 'K I H E C B A' --full-history --topo-order -- file
104check_result 'K I H E C B A' --full-history --date-order -- file
65347030
JH
105check_result 'I E C B A' --simplify-merges -- file
106check_result 'I B A' -- file
107check_result 'I B A' --topo-order -- file
108
109test_done