Post 2.3 cyce (batch #10)
[alt-git.git] / t / t6012-rev-list-simplify.sh
blobfde5e712eb512791c893de7b393fe36e382a3f6d
1 #!/bin/sh
3 test_description='merge simplification'
5 . ./test-lib.sh
7 note () {
8 git tag "$1"
11 unnote () {
12 git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
15 test_expect_success setup '
16 echo "Hi there" >file &&
17 echo "initial" >lost &&
18 git add file lost &&
19 test_tick && git commit -m "Initial file and lost" &&
20 note A &&
22 git branch other-branch &&
24 echo "Hello" >file &&
25 echo "second" >lost &&
26 git add file lost &&
27 test_tick && git commit -m "Modified file and lost" &&
28 note B &&
30 git checkout other-branch &&
32 echo "Hello" >file &&
33 >lost &&
34 git add file lost &&
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 &&
44 test_must_fail git merge -m "merge" master &&
45 >lost && git commit -a -m "merge" &&
46 note E &&
48 echo "Yet another" >elif &&
49 git add elif &&
50 test_tick && git commit -m "Irrelevant change" &&
51 note F &&
53 git checkout master &&
54 echo "Yet another" >elif &&
55 git add elif &&
56 test_tick && git commit -m "Another irrelevant change" &&
57 note G &&
59 test_tick && git merge -m "merge" other-branch &&
60 note H &&
62 echo "Final change" >file &&
63 test_tick && git commit -a -m "Final change" &&
64 note I &&
66 git symbolic-ref HEAD refs/heads/unrelated &&
67 git rm -f "*" &&
68 echo "Unrelated branch" >side &&
69 git add side &&
70 test_tick && git commit -m "Side root" &&
71 note J &&
73 git checkout master &&
74 test_tick && git merge -m "Coolest" unrelated &&
75 note K &&
77 echo "Immaterial" >elif &&
78 git add elif &&
79 test_tick && git commit -m "Last" &&
80 note L
83 FMT='tformat:%P %H | %s'
85 check_outcome () {
86 outcome=$1
87 shift
88 for c in $1
90 echo "$c"
91 done >expect &&
92 shift &&
93 param="$*" &&
94 test_expect_$outcome "log $param" '
95 git log --pretty="$FMT" --parents $param |
96 unnote >actual &&
97 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
98 test_cmp expect check || {
99 cat actual
100 false
105 check_result () {
106 check_outcome success "$@"
109 check_result 'L K J I H G F E D C B A' --full-history
110 check_result 'K I H E C B A' --full-history -- file
111 check_result 'K I H E C B A' --full-history --topo-order -- file
112 check_result 'K I H E C B A' --full-history --date-order -- file
113 check_result 'I E C B A' --simplify-merges -- file
114 check_result 'I B A' -- file
115 check_result 'I B A' --topo-order -- file
116 check_result 'H' --first-parent -- another-file
118 check_result 'E C B A' --full-history E -- lost
119 test_expect_success 'full history simplification without parent' '
120 printf "%s\n" E C B A >expect &&
121 git log --pretty="$FMT" --full-history E -- lost |
122 unnote >actual &&
123 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
124 test_cmp expect check || {
125 cat actual
126 false
130 test_expect_success '--full-diff is not affected by --parents' '
131 git log -p --pretty="%H" --full-diff -- file >expected &&
132 git log -p --pretty="%H" --full-diff --parents -- file >actual &&
133 test_cmp expected actual
136 test_done