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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 21, 2018 at 01:49 UTC
7ce2f4ca0e35a987fb29d11ae06438a93fd48873
1 file changed
+15
-7
contrib/diff-highlight/t/t9400-diff-highlight.sh
+15
-7
@@ -52,15 +52,17 @@ test_strip_patch_header () {
52
# dh_test_setup_history generates a contrived graph such that we have at least
53
# 1 nesting (E) and 2 nestings (F).
54
#
55
-# A master
55
+# A---B master
56
# /
57
# D---E---F branch
58
#
59
# git log --all --graph
60
# * commit
61
-# | A
61
+# | B
62
# | * commit
63
# | | F
64
+# * | commit
65
+# | | A
66
# | * commit
67
# |/
68
# | E
@@ -78,14 +80,20 @@ dh_test_setup_history () {
80
test_tick &&
81
git commit -a -m "E" &&
82
83
+ git checkout master &&
84
+ echo file2 >file &&
85
+ test_tick &&
86
+ git commit -a -m "A" &&
87
+
88
+ git checkout branch &&
89
echo file3 >file &&
90
test_tick &&
91
git commit -a -m "F" &&
92
93
git checkout master &&
86
- echo file2 >file &&
94
+ echo file3 >file &&
95
test_tick &&
88
- git commit -a -m "A"
96
+ git commit -a -m "B"
97
}
98
99
left_trim () {
@@ -246,12 +254,12 @@ test_expect_failure 'diff-highlight treats combining code points as a unit' '
254
test_expect_success 'diff-highlight works with the --graph option' '
255
dh_test_setup_history &&
256
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
258
# trim graph elements so we can do a diff
259
# trim leading space because our trim_graph is not perfect
252
- git log --branches -p --topo-order |
260
+ git log --branches -p --date-order |
261
"$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
254
- git log --branches -p --graph |
262
+ git log --branches -p --date-order --graph |
263
"$DIFF_HIGHLIGHT" | trim_graph | left_trim >graph.act &&
264
test_cmp graph.exp graph.act
265
'