Skip to content

Commit 7ce2f4c

Browse files
peffgitster
authored andcommitted
diff-highlight: test interleaved parallel lines of history
The graph test in t9400 covers the case of two simultaneous branches, but all of the commits during this time are on the right-hand branch. So we test a graph structure like: | | | * commit ... | | but we never see the reverse, a commit on the left-hand branch: | | * | commit ... | | Since this is an easy thing to get wrong when touching the graph-matching code, let's cover it by adding one more commit with its timestamp interleaved with the other branch. Note that we need to pass --date-order to convince Git to show it this way (since --topo-order tries to keep lines of history separate). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e28ae50 commit 7ce2f4c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

contrib/diff-highlight/t/t9400-diff-highlight.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ test_strip_patch_header () {
5252
# dh_test_setup_history generates a contrived graph such that we have at least
5353
# 1 nesting (E) and 2 nestings (F).
5454
#
55-
# A master
55+
# A---B master
5656
# /
5757
# D---E---F branch
5858
#
5959
# git log --all --graph
6060
# * commit
61-
# | A
61+
# | B
6262
# | * commit
6363
# | | F
64+
# * | commit
65+
# | | A
6466
# | * commit
6567
# |/
6668
# | E
@@ -78,14 +80,20 @@ dh_test_setup_history () {
7880
test_tick &&
7981
git commit -a -m "E" &&
8082

83+
git checkout master &&
84+
echo file2 >file &&
85+
test_tick &&
86+
git commit -a -m "A" &&
87+
88+
git checkout branch &&
8189
echo file3 >file &&
8290
test_tick &&
8391
git commit -a -m "F" &&
8492

8593
git checkout master &&
86-
echo file2 >file &&
94+
echo file3 >file &&
8795
test_tick &&
88-
git commit -a -m "A"
96+
git commit -a -m "B"
8997
}
9098

9199
left_trim () {
@@ -246,12 +254,12 @@ test_expect_failure 'diff-highlight treats combining code points as a unit' '
246254
test_expect_success 'diff-highlight works with the --graph option' '
247255
dh_test_setup_history &&
248256
249-
# topo-order so that the order of the commits is the same as with --graph
257+
# date-order so that the commits are interleaved for both
250258
# trim graph elements so we can do a diff
251259
# trim leading space because our trim_graph is not perfect
252-
git log --branches -p --topo-order |
260+
git log --branches -p --date-order |
253261
"$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
254-
git log --branches -p --graph |
262+
git log --branches -p --date-order --graph |
255263
"$DIFF_HIGHLIGHT" | trim_graph | left_trim >graph.act &&
256264
test_cmp graph.exp graph.act
257265
'

0 commit comments

Comments
 (0)