Code

git config: codestyle cleanups
[git.git] / t / t6012-rev-list-simplify.sh
1 #!/bin/sh
3 test_description='merge simplification'
5 . ./test-lib.sh
7 note () {
8         git tag "$1"
9 }
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"
14 unnote () {
15         git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
16 }
18 test_expect_success setup '
19         echo "Hi there" >file &&
20         git add file &&
21         test_tick && git commit -m "Initial file" &&
22         note A &&
24         git branch other-branch &&
26         echo "Hello" >file &&
27         git add file &&
28         test_tick && git commit -m "Modified file" &&
29         note B &&
31         git checkout other-branch &&
33         echo "Hello" >file &&
34         git add file &&
35         test_tick && git commit -m "Modified the file identically" &&
36         note C &&
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 &&
43         test_tick && git merge -m "merge" master &&
44         note E &&
46         echo "Yet another" >elif &&
47         git add elif &&
48         test_tick && git commit -m "Irrelevant change" &&
49         note F &&
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 &&
57         test_tick && git merge -m "merge" other-branch &&
58         note H &&
60         echo "Final change" >file &&
61         test_tick && git commit -a -m "Final change" &&
62         note I
63 '
65 FMT='tformat:%P         %H | %s'
67 check_result () {
68         for c in $1
69         do
70                 echo "$c"
71         done >expect &&
72         shift &&
73         param="$*" &&
74         test_expect_success "log $param" '
75                 git log --pretty="$FMT" --parents $param |
76                 unnote >actual &&
77                 sed -e "s/^.*   \([^ ]*\) .*/\1/" >check <actual &&
78                 test_cmp expect check || {
79                         cat actual
80                         false
81                 }
82         '
83 }
85 check_result 'I H G F E D C B A' --full-history
86 check_result 'I H E C B A' --full-history -- file
87 check_result 'I H E C B A' --full-history --topo-order -- file
88 check_result 'I H E C B A' --full-history --date-order -- file
89 check_result 'I E C B A' --simplify-merges -- file
90 check_result 'I B A' -- file
91 check_result 'I B A' --topo-order -- file
93 test_done