]> git.ipfire.org Git - thirdparty/git.git/commitdiff
lib-log-graph: consolidate colored graph cmp logic
authorAbhishek Kumar <abhishekkumar8222@gmail.com>
Mon, 24 Feb 2020 13:38:14 +0000 (19:08 +0530)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2020 21:15:04 +0000 (13:15 -0800)
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-log-graph.sh
t/t4202-log.sh
t/t4214-log-graph-octopus.sh
t/t4215-log-skewed-merges.sh

index f9c6526eff14a77daa68ce0e23eb33225142c172..1184cceef262283ac65c99985cf9f4ebb3edce68 100755 (executable)
@@ -20,3 +20,9 @@ lib_test_cmp_short_graph () {
        sanitize_log_output >output.sanitized <output &&
        test_i18ncmp expect output.sanitized
 }
+
+lib_test_cmp_colored_graph () {
+       git log --graph --color=always "$@" >output.colors.raw &&
+       test_decode_color <output.colors.raw | sed "s/ *\$//" >output.colors &&
+       test_cmp expect.colors output.colors
+}
index e025a9cfc23c7e7a73c7db2198e3a9c6f1940cef..4694b6d0ce7170e141c17082285772730e499b3e 100755 (executable)
@@ -537,9 +537,7 @@ EOF
 
 test_expect_success 'log --graph with merge with log.graphColors' '
        test_config log.graphColors " blue,invalid-color, cyan, red  , " &&
-       git log --color=always --graph --date-order --pretty=tformat:%s |
-               test_decode_color | sed "s/ *\$//" >actual &&
-       test_cmp expect.colors actual
+       lib_test_cmp_colored_graph --date-order --format=%s
 '
 
 test_expect_success 'log --raw --graph -m with merge' '
index dedb72ace6b8dc8bced9d0a6270b53961e9d9ee3..a0803250984040733a327a9e347651c8686e5e0f 100755 (executable)
@@ -10,6 +10,10 @@ test_cmp_graph () {
        lib_test_cmp_graph --color=never --date-order --format=%s "$@"
 }
 
+test_cmp_colored_graph () {
+       lib_test_cmp_colored_graph --date-order --format=%s "$@"
+}
+
 test_expect_success 'set up merge history' '
        test_commit initial &&
        for i in 1 2 3 4 ; do
@@ -60,9 +64,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '
        <MAGENTA>|<RESET><MAGENTA>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph left octopus-merge
 '
 
 # 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' '
        * initial
        EOF
        test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
-       git log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph octopus-merge
 '
 
 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
        * initial
        EOF
        test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
-       git log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph after-merge
 '
 
 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
        <CYAN>|<RESET><CYAN>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph left after-merge
 '
 
 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' '
        <MAGENTA>|<RESET><MAGENTA>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph after-4 octopus-merge
 '
 
 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
        <CYAN>|<RESET><CYAN>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph after-4 after-merge
 '
 
 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
        <RED>|<RESET><RED>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph after-initial octopus-merge
 '
 
 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
        <RED>|<RESET><RED>/<RESET>
        * initial
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       test_cmp_colored_graph after-initial after-merge
 '
 
 test_done
index e1e94176da449dd70ff5d81e0532e2a327c21cdb..28d0779a8c599ee9eab9b0b31afe1a57bb558c28 100755 (executable)
@@ -305,9 +305,7 @@ test_expect_success 'log --graph with multiple tips and colors' '
        <BLUE>|<RESET><BLUE>/<RESET>
        * 6_A
        EOF
-       git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&
-       test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
-       test_cmp expect.colors actual.colors
+       lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
 '
 
 test_expect_success 'log --graph with multiple tips' '