lib-log-graph: consolidate colored graph cmp logic
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Abhishek Kumar committed
Feb 24, 2020 at 19:08 UTC
ffe005576ac2bd46021fc80112ba7e8e0ab5dd10
4 files changed
+20
-30
t/lib-log-graph.sh
+6
@@ -20,3 +20,9 @@ lib_test_cmp_short_graph () {
20
sanitize_log_output >output.sanitized <output &&
21
test_i18ncmp expect output.sanitized
22
}
23
+
24
+lib_test_cmp_colored_graph () {
25
+ git log --graph --color=always "$@" >output.colors.raw &&
26
+ test_decode_color <output.colors.raw | sed "s/ *\$//" >output.colors &&
27
+ test_cmp expect.colors output.colors
28
+}
t/t4202-log.sh
+1
-3
@@ -537,9 +537,7 @@ EOF
537
538
test_expect_success 'log --graph with merge with log.graphColors' '
539
test_config log.graphColors " blue,invalid-color, cyan, red , " &&
540
- git log --color=always --graph --date-order --pretty=tformat:%s |
541
- test_decode_color | sed "s/ *\$//" >actual &&
542
- test_cmp expect.colors actual
540
+ lib_test_cmp_colored_graph --date-order --format=%s
541
'
542
543
test_expect_success 'log --raw --graph -m with merge' '
t/t4214-log-graph-octopus.sh
+12
-24
@@ -10,6 +10,10 @@ test_cmp_graph () {
10
lib_test_cmp_graph --color=never --date-order --format=%s "$@"
11
}
12
13
+test_cmp_colored_graph () {
14
+ lib_test_cmp_colored_graph --date-order --format=%s "$@"
15
+}
16
+
17
test_expect_success 'set up merge history' '
18
test_commit initial &&
19
for i in 1 2 3 4 ; do
@@ -60,9 +64,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '
64
<MAGENTA>|<RESET><MAGENTA>/<RESET>
65
* initial
66
EOF
63
- git log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&
64
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
65
- test_cmp expect.colors actual.colors
67
+ test_cmp_colored_graph left octopus-merge
68
'
69
70
# Repeat the previous two tests with "normal" octopus merge (i.e.,
@@ -97,9 +99,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
99
* initial
100
EOF
101
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
100
- git log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&
101
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
102
- test_cmp expect.colors actual.colors
102
+ test_cmp_colored_graph octopus-merge
103
'
104
105
test_expect_success 'log --graph with normal octopus merge and child, no color' '
@@ -133,9 +133,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors
133
* initial
134
EOF
135
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
136
- git log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&
137
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
138
- test_cmp expect.colors actual.colors
136
+ test_cmp_colored_graph after-merge
137
'
138
139
test_expect_success 'log --graph with tricky octopus merge and its child, no color' '
@@ -171,9 +169,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co
169
<CYAN>|<RESET><CYAN>/<RESET>
170
* initial
171
EOF
174
- git log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&
175
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
176
- test_cmp expect.colors actual.colors
172
+ test_cmp_colored_graph left after-merge
173
'
174
175
test_expect_success 'log --graph with crossover in octopus merge, no color' '
@@ -215,9 +211,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '
211
<MAGENTA>|<RESET><MAGENTA>/<RESET>
212
* initial
213
EOF
218
- git log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&
219
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
220
- test_cmp expect.colors actual.colors
214
+ test_cmp_colored_graph after-4 octopus-merge
215
'
216
217
test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '
@@ -261,9 +255,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w
255
<CYAN>|<RESET><CYAN>/<RESET>
256
* initial
257
EOF
264
- git log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&
265
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
266
- test_cmp expect.colors actual.colors
258
+ test_cmp_colored_graph after-4 after-merge
259
'
260
261
test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '
@@ -305,9 +297,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo
297
<RED>|<RESET><RED>/<RESET>
298
* initial
299
EOF
308
- git log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&
309
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
310
- test_cmp expect.colors actual.colors
300
+ test_cmp_colored_graph after-initial octopus-merge
301
'
302
303
test_expect_success 'log --graph with unrelated commit and octopus child, no color' '
@@ -351,9 +341,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co
341
<RED>|<RESET><RED>/<RESET>
342
* initial
343
EOF
354
- git log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&
355
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
356
- test_cmp expect.colors actual.colors
344
+ test_cmp_colored_graph after-initial after-merge
345
'
346
347
test_done
t/t4215-log-skewed-merges.sh
+1
-3
@@ -305,9 +305,7 @@ test_expect_success 'log --graph with multiple tips and colors' '
305
<BLUE>|<RESET><BLUE>/<RESET>
306
* 6_A
307
EOF
308
- git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&
309
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
310
- test_cmp expect.colors actual.colors
308
+ lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
309
'
310
311
test_expect_success 'log --graph with multiple tips' '