]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6111-rev-list-treesame.sh
The third batch
[thirdparty/git.git] / t / t6111-rev-list-treesame.sh
CommitLineData
abdea96e
KB
1#!/bin/sh
2#
3# ,---E--. *H----------. * marks !TREESAME parent paths
4# / \ / \*
5# *A--*B---D--*F-*G---------K-*L-*M
6# \ /* \ /
7# `-C-' `-*I-*J
8#
9# A creates "file", B and F change it.
10# Odd merge G takes the old version from B.
11# I changes it, but J reverts it, so K is TREESAME to both parents.
12# H and L both change "file", and M merges those changes.
13
14test_description='TREESAME and limiting'
15
1550bb6e 16GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
17export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
18
abdea96e
KB
19. ./test-lib.sh
20
21note () {
22 git tag "$1"
23}
24
25unnote () {
34ae3b70
JC
26 git name-rev --tags --annotate-stdin | \
27 sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g"
abdea96e
KB
28}
29
30test_expect_success setup '
31 test_commit "Initial file" file "Hi there" A &&
32 git branch other-branch &&
33
34 test_commit "file=Hello" file "Hello" B &&
35 git branch third-branch &&
36
37 git checkout other-branch &&
38 test_commit "Added other" other "Hello" C &&
39
1550bb6e 40 git checkout main &&
abdea96e
KB
41 test_merge D other-branch &&
42
43 git checkout third-branch &&
44 test_commit "Third file" third "Nothing" E &&
45
1550bb6e 46 git checkout main &&
abdea96e
KB
47 test_commit "file=Blah" file "Blah" F &&
48
49 test_tick && git merge --no-commit third-branch &&
50 git checkout third-branch file &&
51 git commit &&
52 note G &&
53 git branch fiddler-branch &&
54
55 git checkout -b part2-branch &&
56 test_commit "file=Part 2" file "Part 2" H &&
57
58 git checkout fiddler-branch &&
59 test_commit "Bad commit" file "Silly" I &&
60
61 test_tick && git revert I && note J &&
62
1550bb6e 63 git checkout main &&
abdea96e 64 test_tick && git merge --no-ff fiddler-branch &&
99094a7a 65 note K &&
abdea96e
KB
66
67 test_commit "file=Part 1" file "Part 1" L &&
68
69 test_tick && test_must_fail git merge part2-branch &&
70 test_commit M file "Parts 1+2"
71'
72
abdea96e
KB
73check_outcome () {
74 outcome=$1
75 shift
e16f434a
JH
76
77 case "$1" in
78 *"("*)
79 FMT="%P %H | %s"
80 munge_actual="
81 s/^\([^ ]*\) \([^ ]*\) .*/(\1)\2/
82 s/ //g
83 s/()//
84 "
85 ;;
86 *)
87 FMT="%H | %s"
88 munge_actual="s/^\([^ ]*\) .*/\1/"
89 ;;
90 esac &&
91 printf "%s\n" $1 >expect &&
92 shift
93
abdea96e
KB
94 param="$*" &&
95 test_expect_$outcome "log $param" '
96 git log --format="$FMT" $param |
97 unnote >actual &&
e16f434a 98 sed -e "$munge_actual" <actual >check &&
5ca812a1 99 test_cmp expect check
abdea96e
KB
100 '
101}
102
103check_result () {
104 check_outcome success "$@"
105}
106
107# Odd merge G drops a change in F. Important that G is listed in all
108# except the most basic list. Achieving this means normal merge D will also be
109# shown in normal full-history, as we can't distinguish unless we do a
110# simplification pass. After simplification, D is dropped but G remains.
53e38358
KB
111# Also, merge simplification of G should not drop the parent B that the default
112# simple history follows.
abdea96e 113check_result 'M L K J I H G F E D C B A'
e16f434a 114check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FE)G (D)F (B)E (BC)D (A)C (A)B A'
abdea96e
KB
115check_result 'M H L K J I G E F D C B A' --topo-order
116check_result 'M L H B A' -- file
53e38358 117check_result '(LH)M (B)L (B)H (A)B A' --parents -- file
d0af663e 118check_result 'M L J I H G F D B A' --full-history -- file
53e38358 119check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FB)G (D)F (BA)D (A)B A' --full-history --parents -- file
9c129eab 120check_result '(LH)M (G)H (J)L (I)J (G)I (FB)G (B)F (A)B A' --simplify-merges -- file
abdea96e
KB
121check_result 'M L K G F D B A' --first-parent
122check_result 'M L G F B A' --first-parent -- file
123
124# Check that odd merge G remains shown when F is the bottom.
125check_result 'M L K J I H G E' F..M
126check_result 'M H L K J I G E' F..M --topo-order
127check_result 'M L H' F..M -- file
53e38358 128check_result '(LH)M (B)L (B)H' --parents F..M -- file
d0af663e 129check_result 'M L J I H G' F..M --full-history -- file
53e38358 130check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FB)G' F..M --full-history --parents -- file
9c129eab 131check_result '(LH)M (G)H (J)L (I)J (G)I (FB)G' F..M --simplify-merges -- file
abdea96e 132check_result 'M L K J I H G' F..M --ancestry-path
d0af663e 133check_result 'M L J I H G' F..M --ancestry-path -- file
53e38358
KB
134check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FE)G' F..M --ancestry-path --parents -- file
135check_result '(LH)M (G)H (J)L (I)J (G)I (FE)G' F..M --ancestry-path --simplify-merges -- file
abdea96e
KB
136check_result 'M L K G' F..M --first-parent
137check_result 'M L G' F..M --first-parent -- file
138
139# Note that G is pruned when E is the bottom, even if it's the same commit list
140# If we want history since E, then we're quite happy to ignore G that took E.
141check_result 'M L K J I H G' E..M --ancestry-path
4d826608 142check_result 'M L J I H' E..M --ancestry-path -- file
bf3418b0 143check_result '(LH)M (K)L (EJ)K (I)J (E)I (E)H' E..M --ancestry-path --parents -- file
4d826608 144check_result '(LH)M (E)H (J)L (I)J (E)I' E..M --ancestry-path --simplify-merges -- file
abdea96e
KB
145
146# Should still be able to ignore I-J branch in simple log, despite limiting
147# to G.
148check_result 'M L K J I H' G..M
149check_result 'M H L K J I' G..M --topo-order
141efdba
KB
150check_result 'M L H' G..M -- file
151check_result '(LH)M (G)L (G)H' G..M --parents -- file
abdea96e
KB
152check_result 'M L J I H' G..M --full-history -- file
153check_result 'M L K J I H' G..M --full-history --parents -- file
154check_result 'M H L J I' G..M --simplify-merges -- file
155check_result 'M L K J I H' G..M --ancestry-path
156check_result 'M L J I H' G..M --ancestry-path -- file
157check_result 'M L K J I H' G..M --ancestry-path --parents -- file
158check_result 'M H L J I' G..M --ancestry-path --simplify-merges -- file
159
160# B..F should be able to simplify the merge D from irrelevant side branch C.
161# Default log should also be free to follow B-D, and ignore C.
162# But --full-history shouldn't drop D on its own - without simplification,
163# we can't decide if the merge from INTERESTING commit C was sensible.
164check_result 'F D C' B..F
141efdba
KB
165check_result 'F' B..F -- file
166check_result '(B)F' B..F --parents -- file
d0af663e 167check_result 'F D' B..F --full-history -- file
53e38358
KB
168check_result '(D)F (BA)D' B..F --full-history --parents -- file
169check_result '(B)F' B..F --simplify-merges -- file
abdea96e 170check_result 'F D' B..F --ancestry-path
4d826608 171check_result 'F' B..F --ancestry-path -- file
bf3418b0 172check_result 'F' B..F --ancestry-path --parents -- file
4d826608 173check_result 'F' B..F --ancestry-path --simplify-merges -- file
abdea96e
KB
174check_result 'F D' B..F --first-parent
175check_result 'F' B..F --first-parent -- file
176
177# E...F should be equivalent to E F ^B, and be able to drop D as above.
141efdba
KB
178check_result 'F' E F ^B -- file # includes D
179check_result 'F' E...F -- file # includes D
abdea96e
KB
180
181# Any sort of full history of C..F should show D, as it's the connection to C,
182# and it differs from it.
183check_result 'F D B' C..F
184check_result 'F B' C..F -- file
53e38358 185check_result '(B)F (A)B' C..F --parents -- file
d0af663e 186check_result 'F D B' C..F --full-history -- file
53e38358
KB
187check_result '(D)F (BC)D (A)B' C..F --full-history --parents -- file
188check_result '(D)F (BC)D (A)B' C..F --simplify-merges -- file
abdea96e 189check_result 'F D' C..F --ancestry-path
d0af663e 190check_result 'F D' C..F --ancestry-path -- file
abdea96e
KB
191check_result 'F D' C..F --ancestry-path --parents -- file
192check_result 'F D' C..F --ancestry-path --simplify-merges -- file
193check_result 'F D B' C..F --first-parent
194check_result 'F B' C..F --first-parent -- file
195
196
197test_done