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