]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6012-rev-list-simplify.sh
Merge branch 'sg/t3420-autostash-fix'
[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
65347030 11unnote () {
2ece6ad2 12 git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g"
65347030
JH
13}
14
15test_expect_success setup '
16 echo "Hi there" >file &&
d5d2fc8b
JH
17 echo "initial" >lost &&
18 git add file lost &&
19 test_tick && git commit -m "Initial file and lost" &&
65347030
JH
20 note A &&
21
22 git branch other-branch &&
23
24 echo "Hello" >file &&
d5d2fc8b
JH
25 echo "second" >lost &&
26 git add file lost &&
27 test_tick && git commit -m "Modified file and lost" &&
65347030
JH
28 note B &&
29
30 git checkout other-branch &&
31
32 echo "Hello" >file &&
d5d2fc8b
JH
33 >lost &&
34 git add file lost &&
65347030
JH
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
d5d2fc8b
JH
43 test_tick &&
44 test_must_fail git merge -m "merge" master &&
45 >lost && git commit -a -m "merge" &&
65347030
JH
46 note E &&
47
48 echo "Yet another" >elif &&
49 git add elif &&
50 test_tick && git commit -m "Irrelevant change" &&
51 note F &&
52
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 &&
58
59 test_tick && git merge -m "merge" other-branch &&
60 note H &&
61
62 echo "Final change" >file &&
63 test_tick && git commit -a -m "Final change" &&
4b7f53da
JH
64 note I &&
65
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 &&
72
73 git checkout master &&
e379fdf3 74 test_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated &&
4b7f53da
JH
75 note K &&
76
77 echo "Immaterial" >elif &&
78 git add elif &&
79 test_tick && git commit -m "Last" &&
80 note L
65347030
JH
81'
82
83FMT='tformat:%P %H | %s'
84
0290bf12
JH
85check_outcome () {
86 outcome=$1
87 shift
65347030
JH
88 for c in $1
89 do
90 echo "$c"
91 done >expect &&
92 shift &&
93 param="$*" &&
0290bf12 94 test_expect_$outcome "log $param" '
65347030
JH
95 git log --pretty="$FMT" --parents $param |
96 unnote >actual &&
97 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
5ca812a1 98 test_cmp expect check
65347030
JH
99 '
100}
101
0290bf12
JH
102check_result () {
103 check_outcome success "$@"
104}
105
4b7f53da
JH
106check_result 'L K J I H G F E D C B A' --full-history
107check_result 'K I H E C B A' --full-history -- file
108check_result 'K I H E C B A' --full-history --topo-order -- file
109check_result 'K I H E C B A' --full-history --date-order -- file
143f1eaf 110check_result 'I E C B A' --simplify-merges -- file
65347030
JH
111check_result 'I B A' -- file
112check_result 'I B A' --topo-order -- file
36ed1913 113check_result 'H' --first-parent -- another-file
65347030 114
d5d2fc8b
JH
115check_result 'E C B A' --full-history E -- lost
116test_expect_success 'full history simplification without parent' '
117 printf "%s\n" E C B A >expect &&
118 git log --pretty="$FMT" --full-history E -- lost |
119 unnote >actual &&
120 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
5ca812a1 121 test_cmp expect check
d5d2fc8b
JH
122'
123
53d00b39
TR
124test_expect_success '--full-diff is not affected by --parents' '
125 git log -p --pretty="%H" --full-diff -- file >expected &&
126 git log -p --pretty="%H" --full-diff --parents -- file >actual &&
127 test_cmp expected actual
128'
129
65347030 130test_done