{"thread":{"id":"52816","subject":"[GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic","startedAt":"2020-02-16T13:48:48Z","lastAt":"2020-02-24T21:17:17Z","messageCount":18,"participants":["Abhishek Kumar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"391866","messageId":"20200216134750.18947-1-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":null,"subject":"[GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-16T13:47:46Z","receivedAt":"2020-02-16T13:48:48Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Logic for comparing log graphs is duplicated across test scripts.\n\nThis patchset consolidates such logic into lib-log-graph.\n\nHelped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n1. I don't think this patchset requires a cover letter or extended\ncommit descriptions - Fairly simple, straightforward changes.\n2. This patchset closes issue #471 from gitgitgadget.\n\n t/lib-log-graph.sh | 39 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 39 insertions(+)\n create mode 100644 t/lib-log-graph.sh\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nnew file mode 100644\nindex 0000000000..999f2600de\n--- /dev/null\n+++ b/t/lib-log-graph.sh\n@@ -0,0 +1,39 @@\n+# Helpers shared by the test scripts for comparing log graphs.\n+\n+sanitize_output() {\n+\tsed -e 's/ *$//' \\\n+\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n+\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n+\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/, 0 deletions(-)//' \\\n+\t    -e 's/, 0 insertions(+)//' \\\n+\t    -e 's/ 1 files changed, / 1 file changed, /' \\\n+\t    -e 's/, 1 deletions(-)/, 1 deletion(-)/' \\\n+\t    -e 's/, 1 insertions(+)/, 1 insertion(+)/' \\\n+\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n+}\n+\n+# Assume expected graph is in file `expect`\n+test_cmp_graph_file() {\n+\tgit log --graph \"$@\" >output &&\n+\tsanitize_output >output.trimmed <output &&\n+\ttest_i18ncmp expect output.trimmed\n+}\n+\n+test_cmp_graph() {\n+\tcat >expect &&\n+\ttest_cmp_graph_file \"$@\"\n+}\n+\n+# Assume expected graph is in file `expect.colors`\n+test_cmp_colored_graph_file() {\n+\tgit log --graph --color=always \"$@\" >output.colors.raw &&\n+\ttest_decode_color <output.colors.raw | sed \"s/ *\\$//\" >output.colors &&\n+\ttest_cmp expect.colors output.colors\n+}\n+\n+test_cmp_colored_graph() {\n+\tcat >expect.colors &&\n+\ttest_cmp_colored_graph_file \"$@\"\n+}\n-- \n2.25.0\n\n"},{"id":"391867","messageId":"20200216134750.18947-2-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch 2/5] t3430: use lib-log-graph functions","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-16T13:47:47Z","receivedAt":"2020-02-16T13:48:48Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/t3430-rebase-merges.sh | 24 +++++++++---------------\n 1 file changed, 9 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh\nindex e72ca348ea..74c61fa787 100755\n--- a/t/t3430-rebase-merges.sh\n+++ b/t/t3430-rebase-merges.sh\n@@ -20,13 +20,7 @@ Initial setup:\n '\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-rebase.sh\n-\n-test_cmp_graph () {\n-\tcat >expect &&\n-\tgit log --graph --boundary --format=%s \"$@\" >output &&\n-\tsed \"s/ *$//\" <output >output.trimmed &&\n-\ttest_cmp expect output.trimmed\n-}\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n test_expect_success 'setup' '\n \twrite_script replace-editor.sh <<-\\EOF &&\n@@ -84,7 +78,7 @@ test_expect_success 'create completely different structure' '\n \ttest_config sequence.editor \\\"\"$PWD\"/replace-editor.sh\\\" &&\n \ttest_tick &&\n \tgit rebase -i -r A master &&\n-\ttest_cmp_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary <<-\\EOF\n \t*   Merge the topic branch '\\''onebranch'\\''\n \t|\\\n \t| * D\n@@ -201,7 +195,7 @@ test_expect_success 'with a branch tip that was cherry-picked already' '\n \tgit checkout already-upstream &&\n \ttest_tick &&\n \tgit rebase -i -r upstream-with-a2 &&\n-\ttest_cmp_graph upstream-with-a2.. <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary upstream-with-a2.. <<-\\EOF\n \t*   Merge branch A\n \t|\\\n \t| * A1\n@@ -219,7 +213,7 @@ test_expect_success 'do not rebase cousins unless asked for' '\n \ttest_cmp_rev HEAD $before &&\n \ttest_tick &&\n \tgit rebase --rebase-merges=rebase-cousins HEAD^ &&\n-\ttest_cmp_graph HEAD^.. <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary HEAD^.. <<-\\EOF\n \t*   Merge the topic branch '\\''onebranch'\\''\n \t|\\\n \t| * D\n@@ -311,7 +305,7 @@ test_expect_success 'root commits' '\n \ttest $(git rev-parse second-root^0) != $(git rev-parse HEAD^) &&\n \ttest $(git rev-parse second-root:second-root.t) = \\\n \t\t$(git rev-parse HEAD^:second-root.t) &&\n-\ttest_cmp_graph HEAD <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --boundary HEAD <<-\\EOF &&\n \t*   Merge the 3rd root\n \t|\\\n \t| * third-root\n@@ -347,7 +341,7 @@ test_expect_success 'A root commit can be a cousin, treat it that way' '\n \ttest_tick &&\n \tgit rebase -f -r HEAD^ &&\n \ttest_cmp_rev ! HEAD^2 khnum &&\n-\ttest_cmp_graph HEAD^.. <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --boundary HEAD^.. <<-\\EOF &&\n \t*   Merge branch '\\''khnum'\\'' into asherah\n \t|\\\n \t| * yama\n@@ -355,7 +349,7 @@ test_expect_success 'A root commit can be a cousin, treat it that way' '\n \tEOF\n \ttest_tick &&\n \tgit rebase --rebase-merges=rebase-cousins HEAD^ &&\n-\ttest_cmp_graph HEAD^.. <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary HEAD^.. <<-\\EOF\n \t*   Merge branch '\\''khnum'\\'' into asherah\n \t|\\\n \t| * yama\n@@ -402,7 +396,7 @@ test_expect_success 'octopus merges' '\n \tgit rebase -i --force-rebase -r HEAD^^ &&\n \ttest \"Hank\" = \"$(git show -s --format=%an HEAD)\" &&\n \ttest \"$before\" != $(git rev-parse HEAD) &&\n-\ttest_cmp_graph HEAD^^.. <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary HEAD^^.. <<-\\EOF\n \t*-.   Tüntenfüsch\n \t|\\ \\\n \t| | * three\n@@ -478,7 +472,7 @@ test_expect_success '--rebase-merges with message matched with onto label' '\n \tgit checkout -b onto-label E &&\n \tgit merge -m onto G &&\n \tgit rebase --rebase-merges --force-rebase E &&\n-\ttest_cmp_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --boundary <<-\\EOF\n \t*   onto\n \t|\\\n \t| * G\n-- \n2.25.0\n\n"},{"id":"391868","messageId":"20200216134750.18947-3-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch 3/5] t4215: use lib-log-graph functions","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-16T13:47:48Z","receivedAt":"2020-02-16T13:48:50Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/t4215-log-skewed-merges.sh | 26 ++++++++++----------------\n 1 file changed, 10 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\nindex 1d0d3240ff..bca478cb83 100755\n--- a/t/t4215-log-skewed-merges.sh\n+++ b/t/t4215-log-skewed-merges.sh\n@@ -3,13 +3,7 @@\n test_description='git log --graph of skewed merges'\n \n . ./test-lib.sh\n-\n-check_graph () {\n-\tcat >expect &&\n-\tgit log --graph --pretty=tformat:%s \"$@\" >actual.raw &&\n-\tsed \"s/ *$//\" actual.raw >actual &&\n-\ttest_cmp expect actual\n-}\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n test_expect_success 'log --graph with merge fusing with its left and right neighbors' '\n \tgit checkout --orphan _p &&\n@@ -22,7 +16,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh\n \tgit checkout _p && git merge --no-ff _r -m G &&\n \tgit checkout @^^ && git merge --no-ff _p -m H &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*   H\n \t|\\\n \t| *   G\n@@ -50,7 +44,7 @@ test_expect_success 'log --graph with left-skewed merge' '\n \tgit checkout 0_p && git merge --no-ff 0_s -m 0_G &&\n \tgit checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*-----.   0_H\n \t|\\ \\ \\ \\\n \t| | | | * 0_G\n@@ -84,7 +78,7 @@ test_expect_success 'log --graph with nested left-skewed merge' '\n \tgit checkout 1_p && git merge --no-ff 1_r -m 1_G &&\n \tgit checkout @^^ && git merge --no-ff 1_p -m 1_H &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*   1_H\n \t|\\\n \t| *   1_G\n@@ -116,7 +110,7 @@ test_expect_success 'log --graph with nested left-skewed merge following normal\n \tgit checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&\n \tgit checkout 2_p && git merge --no-ff 2_s -m 2_K &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*   2_K\n \t|\\\n \t| *   2_J\n@@ -152,7 +146,7 @@ test_expect_success 'log --graph with nested right-skewed merge following left-s\n \tgit checkout 3_p && git merge --no-ff 3_r -m 3_H &&\n \tgit checkout @^^ && git merge --no-ff 3_p -m 3_J &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*   3_J\n \t|\\\n \t| *   3_H\n@@ -183,7 +177,7 @@ test_expect_success 'log --graph with right-skewed merge following a left-skewed\n \tgit merge --no-ff 4_p -m 4_G &&\n \tgit checkout @^^ && git merge --no-ff 4_s -m 4_H &&\n \n-\tcheck_graph --date-order <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s --date-order <<-\\EOF\n \t*   4_H\n \t|\\\n \t| *   4_G\n@@ -219,7 +213,7 @@ test_expect_success 'log --graph with octopus merge with column joining its penu\n \tgit checkout 5_r &&\n \tgit merge --no-ff 5_s -m 5_H &&\n \n-\tcheck_graph <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n \t*   5_H\n \t|\\\n \t| *-.   5_G\n@@ -258,7 +252,7 @@ test_expect_success 'log --graph with multiple tips' '\n \tgit checkout 6_1 &&\n \tgit merge --no-ff 6_2 -m 6_I &&\n \n-\tcheck_graph 6_1 6_3 6_5 <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s 6_1 6_3 6_5 <<-\\EOF\n \t*   6_I\n \t|\\\n \t| | *   6_H\n@@ -337,7 +331,7 @@ test_expect_success 'log --graph with multiple tips' '\n \tgit checkout -b M_7 7_1 &&\n \tgit merge --no-ff 7_2 7_3 -m 7_M4 &&\n \n-\tcheck_graph M_1 M_3 M_5 M_7 <<-\\EOF\n+\ttest_cmp_graph --pretty=tformat:%s M_1 M_3 M_5 M_7 <<-\\EOF\n \t*   7_M1\n \t|\\\n \t| | *   7_M2\n-- \n2.25.0\n\n"},{"id":"391869","messageId":"20200216134750.18947-5-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch 5/5] t4202: use lib-log-graph functions","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-16T13:47:50Z","receivedAt":"2020-02-16T13:48:59Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/t4202-log.sh | 49 ++++++++++---------------------------------------\n 1 file changed, 10 insertions(+), 39 deletions(-)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 192347a3e1..403d88bb33 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -5,6 +5,7 @@ test_description='git log'\n . ./test-lib.sh\n . \"$TEST_DIRECTORY/lib-gpg.sh\"\n . \"$TEST_DIRECTORY/lib-terminal.sh\"\n+. \"$TEST_DIRECTORY/lib-log-graph.sh\"\n \n test_expect_success setup '\n \n@@ -452,8 +453,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph' '\n-\tgit log --graph --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph_file --pretty=tformat:%s\n '\n \n cat > expect <<EOF\n@@ -467,8 +467,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph --line-prefix=\"123 \"' '\n-\tgit log --graph --line-prefix=\"123 \" --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph_file --line-prefix=\"123 \" --pretty=tformat:%s\n '\n \n test_expect_success 'set up merge history' '\n@@ -495,9 +494,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph with merge' '\n-\tgit log --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph_file --date-order --pretty=tformat:%s\n '\n \n cat > expect <<\\EOF\n@@ -516,9 +513,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph --line-prefix=\"| | | \" with merge' '\n-\tgit log --line-prefix=\"| | | \" --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph_file --line-prefix=\"| | | \" --date-order --pretty=tformat:%s\n '\n \n cat > expect.colors <<\\EOF\n@@ -538,9 +533,7 @@ EOF\n \n test_expect_success 'log --graph with merge with log.graphColors' '\n \ttest_config log.graphColors \" blue,invalid-color, cyan, red  , \" &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s |\n-\t\ttest_decode_color | sed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect.colors actual\n+\ttest_cmp_colored_graph_file --date-order --pretty=tformat:%s\n '\n \n test_expect_success 'log --raw --graph -m with merge' '\n@@ -1213,24 +1206,8 @@ cat >expect <<\\EOF\n   +one\n EOF\n \n-sanitize_output () {\n-\tsed -e 's/ *$//' \\\n-\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n-\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n-\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/, 0 deletions(-)//' \\\n-\t    -e 's/, 0 insertions(+)//' \\\n-\t    -e 's/ 1 files changed, / 1 file changed, /' \\\n-\t    -e 's/, 1 deletions(-)/, 1 deletion(-)/' \\\n-\t    -e 's/, 1 insertions(+)/, 1 insertion(+)/' \\\n-\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n-}\n-\n test_expect_success 'log --graph with diff and stats' '\n-\tgit log --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\ttest_cmp_graph_file --no-renames --graph --pretty=short --stat -p\n '\n \n cat >expect <<\\EOF\n@@ -1505,9 +1482,7 @@ cat >expect <<\\EOF\n EOF\n \n test_expect_success 'log --line-prefix=\"*** \" --graph with diff and stats' '\n-\tgit log --line-prefix=\"*** \" --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\ttest_cmp_graph_file --line-prefix=\"*** \" --no-renames --graph --pretty=short --stat -p\n '\n \n cat >expect <<-\\EOF\n@@ -1529,9 +1504,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-status' '\n-\tgit log --graph --format=%s --name-status tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph_file --pretty=tformat:%s --name-status tangle..reach\n '\n \n cat >expect <<-\\EOF\n@@ -1553,9 +1526,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-only' '\n-\tgit log --graph --format=%s --name-only tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph_file --pretty=tformat:%s --name-only tangle..reach\n '\n \n test_expect_success 'dotdot is a parent directory' '\n-- \n2.25.0\n\n"},{"id":"391870","messageId":"20200216134750.18947-4-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch 4/5] t4214: use lib-log-graph functions","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-16T13:47:49Z","receivedAt":"2020-02-16T13:48:59Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/t4214-log-graph-octopus.sh | 86 ++++++++----------------------------\n 1 file changed, 19 insertions(+), 67 deletions(-)\n\ndiff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh\nindex 40d27db674..e85cf07d2c 100755\n--- a/t/t4214-log-graph-octopus.sh\n+++ b/t/t4214-log-graph-octopus.sh\n@@ -3,6 +3,7 @@\n test_description='git log --graph of skewed left octopus merge.'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n test_expect_success 'set up merge history' '\n \ttest_commit initial &&\n@@ -24,7 +25,7 @@ test_expect_success 'set up merge history' '\n '\n \n test_expect_success 'log --graph with tricky octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order left octopus-merge <<-\\EOF\n \t* left\n \t| *-.   octopus-merge\n \t|/|\\ \\\n@@ -37,14 +38,11 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge with colors' '\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order left octopus-merge <<-\\EOF\n \t* left\n \t<RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge\n \t<RED>|<RESET><RED>/<RESET><YELLOW>|<RESET><BLUE>\\<RESET> <MAGENTA>\\<RESET>\n@@ -57,16 +55,13 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n # Repeat the previous two tests with \"normal\" octopus merge (i.e.,\n # without the first parent skewing to the \"left\" branch column).\n \n test_expect_success 'log --graph with normal octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order octopus-merge <<-\\EOF\n \t*---.   octopus-merge\n \t|\\ \\ \\\n \t| | | * 4\n@@ -78,13 +73,11 @@ test_expect_success 'log --graph with normal octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus merge with colors' '\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order octopus-merge <<-\\EOF\n \t*<YELLOW>-<RESET><YELLOW>-<RESET><BLUE>-<RESET><BLUE>.<RESET>   octopus-merge\n \t<RED>|<RESET><GREEN>\\<RESET> <YELLOW>\\<RESET> <BLUE>\\<RESET>\n \t<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 4\n@@ -96,14 +89,10 @@ test_expect_success 'log --graph with normal octopus merge with colors' '\n \t<BLUE>|<RESET><BLUE>/<RESET>\n \t* initial\n \tEOF\n-\ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with normal octopus merge and child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order after-merge <<-\\EOF\n \t* after-merge\n \t*---.   octopus-merge\n \t|\\ \\ \\\n@@ -116,13 +105,11 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus and child merge with colors' '\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order after-merge <<-\\EOF\n \t* after-merge\n \t*<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge\n \t<GREEN>|<RESET><YELLOW>\\<RESET> <BLUE>\\<RESET> <MAGENTA>\\<RESET>\n@@ -135,14 +122,10 @@ test_expect_success 'log --graph with normal octopus and child merge with colors\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order left after-merge <<-\\EOF\n \t* left\n \t| * after-merge\n \t| *-.   octopus-merge\n@@ -156,14 +139,10 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child with colors' '\n-\ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order left after-merge <<-\\EOF\n \t* left\n \t<RED>|<RESET> * after-merge\n \t<RED>|<RESET> *<CYAN>-<RESET><CYAN>.<RESET>   octopus-merge\n@@ -177,13 +156,10 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with crossover in octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --date-order after-4 octopus-merge <<-\\EOF\n \t* after-4\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -200,14 +176,11 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge with colors' '\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order after-4 octopus-merge <<-\\EOF\n \t* after-4\n \t<RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><RED>-<RESET><RED>.<RESET>   octopus-merge\n \t<RED>|<RESET> <GREEN>|<RESET><YELLOW>\\<RESET> <BLUE>\\<RESET> <RED>\\<RESET>\n@@ -224,13 +197,10 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --date-order after-4 after-merge <<-\\EOF\n \t* after-4\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -248,14 +218,11 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order after-4 after-merge <<-\\EOF\n \t* after-4\n \t<RED>|<RESET> * after-merge\n \t<RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><RED>-<RESET><RED>.<RESET>   octopus-merge\n@@ -273,13 +240,10 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order --pretty=tformat:%s after-initial octopus-merge <<-\\EOF\n \t* after-initial\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -296,14 +260,11 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order after-initial octopus-merge <<-\\EOF\n \t* after-initial\n \t<RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge\n \t<RED>|<RESET> <GREEN>|<RESET><YELLOW>\\<RESET> <BLUE>\\<RESET> <MAGENTA>\\<RESET>\n@@ -320,13 +281,10 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order after-initial after-merge <<-\\EOF\n \t* after-initial\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -344,14 +302,11 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child with colors' '\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tcat >expect.colors <<-\\EOF &&\n+\ttest_cmp_colored_graph --pretty=tformat:%s --date-order after-initial after-merge <<-\\EOF\n \t* after-initial\n \t<RED>|<RESET> * after-merge\n \t<RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><CYAN>-<RESET><CYAN>.<RESET>   octopus-merge\n@@ -369,9 +324,6 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n '\n \n test_done\n-- \n2.25.0\n\n"},{"id":"391884","messageId":"xmqqk14mm61r.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-17T00:05:52Z","receivedAt":"2020-02-17T00:06:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Logic for comparing log graphs is duplicated across test scripts.\n> ...\n>  t/lib-log-graph.sh | 39 +++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 39 insertions(+)\n>  create mode 100644 t/lib-log-graph.sh\n\nThe presentation order of the patches may be less than ideal, in\nthat it introduces totally unused code in step 1/5 that is hard to\ncompare with what it will be used to replace with, and it is\nimpossible to tell if the potential issues readers see in this step\nare merely inherited from existing tests or new issues introduced by\nthis series, before reading the later steps.\n\n> diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\n> new file mode 100644\n> index 0000000000..999f2600de\n> --- /dev/null\n> +++ b/t/lib-log-graph.sh\n> @@ -0,0 +1,39 @@\n> +# Helpers shared by the test scripts for comparing log graphs.\n> +\n> +sanitize_output() {\n\nOne SP around both sides of ().  I suspect that all helper functions\nin this patch has this style violation.\n\nAs a library-ish function that can be used outside individual test\nscript, \"output\" without any clarification is too broad a word to\nact as an object of sanitizing.  Is this function to sanitize the\noutput from \"git log\"?  Perhaps at the minimum, it should be called\nsanitize_log_output then.\n\n> +\tsed -e 's/ *$//' \\\n> +\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n> +\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n> +\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n> +\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n\nThese are understandable anonymization; so is the last \"index\" one.\n\n> +\t    -e 's/, 0 deletions(-)//' \\\n> +\t    -e 's/, 0 insertions(+)//' \\\n> +\t    -e 's/ 1 files changed, / 1 file changed, /' \\\n> +\t    -e 's/, 1 deletions(-)/, 1 deletion(-)/' \\\n> +\t    -e 's/, 1 insertions(+)/, 1 insertion(+)/' \\\n\nThese might deserve comments.  IIUC, all of these are historical\naccident and no longer necessary.\n\n> +\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n> +}\n> +\n> +# Assume expected graph is in file `expect`\n> +test_cmp_graph_file() {\n> +\tgit log --graph \"$@\" >output &&\n> +\tsanitize_output >output.trimmed <output &&\n\nPay attention to the names.  If you are \"sanitizing\", then the\nresult is not \"trimmed\".  Call it \"sanitized\".\n\n> +\ttest_i18ncmp expect output.trimmed\n> +}\n> +\n> +test_cmp_graph() {\n> +\tcat >expect &&\n> +\ttest_cmp_graph_file \"$@\"\n> +}\n\nI am not sure if this wrapper is useful or obscuring.  Open coding\nthe caller of this wrapper, i.e.\n\n\tcat >expect <<-\\EOF &&\n\texpected pattern\n\tEOF\n\ttest_cmp_graph_file $args\n\nis not all that cumbersome, and it might make it more transparent to\nthe readers what is going on.  I'd need to see the callsites in\nlater steps to decide it is a good idea.\n\n> +# Assume expected graph is in file `expect.colors`\n> +test_cmp_colored_graph_file() {\n> +\tgit log --graph --color=always \"$@\" >output.colors.raw &&\n> +\ttest_decode_color <output.colors.raw | sed \"s/ *\\$//\" >output.colors &&\n> +\ttest_cmp expect.colors output.colors\n> +}\n> +\n> +test_cmp_colored_graph() {\n> +\tcat >expect.colors &&\n> +\ttest_cmp_colored_graph_file \"$@\"\n> +}\n\nSo unlike test_cmp_graph family, colored counterparts do not\nanonymize?  That sounds a bit harder to use, but we cannot really\ntell if that is an issue before seeing the callsites in later steps.\n\nThanks.\n"},{"id":"392080","messageId":"xmqqy2syfq48.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200216134750.18947-2-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch 2/5] t3430: use lib-log-graph functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-19T17:23:19Z","receivedAt":"2020-02-19T17:23:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n> ---\n>  t/t3430-rebase-merges.sh | 24 +++++++++---------------\n>  1 file changed, 9 insertions(+), 15 deletions(-)\n>\n> diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh\n> index e72ca348ea..74c61fa787 100755\n> --- a/t/t3430-rebase-merges.sh\n> +++ b/t/t3430-rebase-merges.sh\n> @@ -20,13 +20,7 @@ Initial setup:\n>  '\n>  . ./test-lib.sh\n>  . \"$TEST_DIRECTORY\"/lib-rebase.sh\n> -\n> -test_cmp_graph () {\n> -\tcat >expect &&\n> -\tgit log --graph --boundary --format=%s \"$@\" >output &&\n> -\tsed \"s/ *$//\" <output >output.trimmed &&\n> -\ttest_cmp expect output.trimmed\n> -}\n> +. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n>  \n>  test_expect_success 'setup' '\n>  \twrite_script replace-editor.sh <<-\\EOF &&\n> @@ -84,7 +78,7 @@ test_expect_success 'create completely different structure' '\n>  \ttest_config sequence.editor \\\"\"$PWD\"/replace-editor.sh\\\" &&\n>  \ttest_tick &&\n>  \tgit rebase -i -r A master &&\n> -\ttest_cmp_graph <<-\\EOF\n> +\ttest_cmp_graph --pretty=tformat:%s --boundary <<-\\EOF\n\nThe original used a more readble short-hand \"--format=%s\"; was there\na strong reason why we wanted to use \"--pretty=tformat:%s\"?\n\nThe same comment applies to all the following hunks.\n\nI actually have to wonder if this is a good change at all.  Surely\nyou lost one local and specialized test helper and replaced its use\nwith a more flexible one from the lib-log-graph file, but because\nthe one from the lib-log-graph is more flexible, you now need to\ntell it what options the tests want to give to the \"git log\"\ncommand, the same thing over and over, which would make it much more\nerror prone, no?\n\nIt would have been more acceptable if we kept test_cmp_graph a local\nand specialized test helper defined in this file, but changed its\nimplementation (i.e. the 4 lines we see above) to call to a more\ngeneric helper function defined in lib-log-graph file, i.e.\n\n\ttest_cmp_graph () {\n\t\ttest_cmp_graph_from_lib --boundary --format=%s \"$@\"\n\t}\n\nbut then the more flexible helper defined in lib-log-graph file\ncannot squat on the short-and-sweet name \"test_cmp_graph\" that is\nalready used in the test scripts without unnecessary churn.\n\nI dunno.\n"},{"id":"392081","messageId":"xmqqtv3mfpzh.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200216134750.18947-3-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch 3/5] t4215: use lib-log-graph functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-19T17:26:10Z","receivedAt":"2020-02-19T17:26:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n> ---\n>  t/t4215-log-skewed-merges.sh | 26 ++++++++++----------------\n>  1 file changed, 10 insertions(+), 16 deletions(-)\n>\n> diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\n> index 1d0d3240ff..bca478cb83 100755\n> --- a/t/t4215-log-skewed-merges.sh\n> +++ b/t/t4215-log-skewed-merges.sh\n> @@ -3,13 +3,7 @@\n>  test_description='git log --graph of skewed merges'\n>  \n>  . ./test-lib.sh\n> -\n> -check_graph () {\n> -\tcat >expect &&\n> -\tgit log --graph --pretty=tformat:%s \"$@\" >actual.raw &&\n> -\tsed \"s/ *$//\" actual.raw >actual &&\n> -\ttest_cmp expect actual\n> -}\n> +. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n>  \n>  test_expect_success 'log --graph with merge fusing with its left and right neighbors' '\n>  \tgit checkout --orphan _p &&\n> @@ -22,7 +16,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh\n>  \tgit checkout _p && git merge --no-ff _r -m G &&\n>  \tgit checkout @^^ && git merge --no-ff _p -m H &&\n>  \n> -\tcheck_graph <<-\\EOF\n> +\ttest_cmp_graph --pretty=tformat:%s <<-\\EOF\n\nAlmost exactly the same comment as [2/5] applies here, but luckily\nthe name of the local helper used here is check_graph, so we can\ndiscard all the hunks after -22,7 above and instead use\n\n\tcheck_graph () {\n\t\ttest_cmp_graph --format:%s \"$@\"\n\t}\n\nto reduce the code churn, I would think.\n"},{"id":"392082","messageId":"xmqqpneafptt.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200216134750.18947-4-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch 4/5] t4214: use lib-log-graph functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-19T17:29:34Z","receivedAt":"2020-02-19T17:29:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> @@ -24,7 +25,7 @@ test_expect_success 'set up merge history' '\n>  '\n>  \n>  test_expect_success 'log --graph with tricky octopus merge, no color' '\n> -\tcat >expect.uncolored <<-\\EOF &&\n> +\ttest_cmp_graph --pretty=tformat:%s --color=never --date-order left octopus-merge <<-\\EOF\n>  \t* left\n>  \t| *-.   octopus-merge\n>  \t|/|\\ \\\n> @@ -37,14 +38,11 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '\n>  \t|/\n>  \t* initial\n>  \tEOF\n> -\tgit log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&\n> -\tsed \"s/ *\\$//\" actual.raw >actual &&\n> -\ttest_cmp expect.uncolored actual\n>  '\n>  \n>  test_expect_success 'log --graph with tricky octopus merge with colors' '\n>  \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n> -\tcat >expect.colors <<-\\EOF &&\n> +\ttest_cmp_colored_graph --pretty=tformat:%s --date-order left octopus-merge <<-\\EOF\n>  \t* left\n>  \t<RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge\n>  \t<RED>|<RESET><RED>/<RESET><YELLOW>|<RESET><BLUE>\\<RESET> <MAGENTA>\\<RESET>\n> @@ -57,16 +55,13 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n>  \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n>  \t* initial\n>  \tEOF\n> -\tgit log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&\n> -\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n> -\ttest_cmp expect.colors actual.colors\n>  '\n> ...\n\nUnlike the previous two steps, this does seem to make the script\ncleaner and slightly more readable (it is still unreadable but that\nis mostly due to the contents of the here-doc text and cannot be\nhelped ;-).\n\n"},{"id":"392083","messageId":"xmqqlfoyfpr9.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200216134750.18947-5-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch 5/5] t4202: use lib-log-graph functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-19T17:31:06Z","receivedAt":"2020-02-19T17:31:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n> ---\n>  t/t4202-log.sh | 49 ++++++++++---------------------------------------\n>  1 file changed, 10 insertions(+), 39 deletions(-)\n>\n> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n> index 192347a3e1..403d88bb33 100755\n> --- a/t/t4202-log.sh\n> +++ b/t/t4202-log.sh\n> @@ -5,6 +5,7 @@ test_description='git log'\n>  . ./test-lib.sh\n>  . \"$TEST_DIRECTORY/lib-gpg.sh\"\n>  . \"$TEST_DIRECTORY/lib-terminal.sh\"\n> +. \"$TEST_DIRECTORY/lib-log-graph.sh\"\n>  \n>  test_expect_success setup '\n>  \n> @@ -452,8 +453,7 @@ cat > expect <<EOF\n>  EOF\n>  \n>  test_expect_success 'simple log --graph' '\n> -\tgit log --graph --pretty=tformat:%s >actual &&\n> -\ttest_cmp expect actual\n> +\ttest_cmp_graph_file --pretty=tformat:%s\n>  '\n>  \n>  cat > expect <<EOF\n> @@ -467,8 +467,7 @@ cat > expect <<EOF\n>  EOF\n>  \n>  test_expect_success 'simple log --graph --line-prefix=\"123 \"' '\n> -\tgit log --graph --line-prefix=\"123 \" --pretty=tformat:%s >actual &&\n> -\ttest_cmp expect actual\n> +\ttest_cmp_graph_file --line-prefix=\"123 \" --pretty=tformat:%s\n>  '\n\nLike [4/5], and unlike [2/5] and [3/5], this step also does seem\nlike an improvement.\n"},{"id":"392084","messageId":"xmqqh7zmfpod.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"xmqqk14mm61r.fsf@gitster-ct.c.googlers.com","subject":"Re: [GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-19T17:32:50Z","receivedAt":"2020-02-19T17:32:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here is what I said in the message I am responding to in the patch\nform.\n\n t/lib-log-graph.sh | 20 +++++++++++++-------\n 1 file changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nindex 999f2600de..bc70f01e84 100644\n--- a/t/lib-log-graph.sh\n+++ b/t/lib-log-graph.sh\n@@ -1,6 +1,12 @@\n # Helpers shared by the test scripts for comparing log graphs.\n \n-sanitize_output() {\n+sanitize_output () {\n+\t# Versions of Git that predate 7f814632 (\"Use correct grammar\n+\t# in diffstat summary line\", 2012-02-01) did not correctly use\n+\t# singular when one path was involved, and a handful of rules\n+\t# were added to work with both older and newer versions of Git\n+\t# back then.  These are probably not relevant anymore, and\n+\t# we'd want to lose them someday...\n \tsed -e 's/ *$//' \\\n \t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n \t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n@@ -15,25 +21,25 @@ sanitize_output() {\n }\n \n # Assume expected graph is in file `expect`\n-test_cmp_graph_file() {\n+test_cmp_graph_file () {\n \tgit log --graph \"$@\" >output &&\n-\tsanitize_output >output.trimmed <output &&\n-\ttest_i18ncmp expect output.trimmed\n+\tsanitize_output >output.sanitized <output &&\n+\ttest_i18ncmp expect output.sanitized\n }\n \n-test_cmp_graph() {\n+test_cmp_graph () {\n \tcat >expect &&\n \ttest_cmp_graph_file \"$@\"\n }\n \n # Assume expected graph is in file `expect.colors`\n-test_cmp_colored_graph_file() {\n+test_cmp_colored_graph_file () {\n \tgit log --graph --color=always \"$@\" >output.colors.raw &&\n \ttest_decode_color <output.colors.raw | sed \"s/ *\\$//\" >output.colors &&\n \ttest_cmp expect.colors output.colors\n }\n \n-test_cmp_colored_graph() {\n+test_cmp_colored_graph () {\n \tcat >expect.colors &&\n \ttest_cmp_colored_graph_file \"$@\"\n }\n-- \n2.25.1-440-g39558b81cc\n\n"},{"id":"392159","messageId":"20200220091528.28472-1-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC PATCH v2 0/2] Consolidate test_cmp_graph logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-20T09:15:26Z","receivedAt":"2020-02-20T09:16:31Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Changes in v2:\n- Arrange patches on functions changed, rather than files changed.\n- Use specialized helper functions calling library functions.\n- Fix SP and other style issues.\n\nI would like to thank Junio for his suggestions - Really cut down on the\nneedless changes.\n\nCloses gitgitgadget issue #471.\n\nAbhishek Kumar (2):\n  lib-log-graph: consolidate test_cmp_graph logic\n  lib-log-graph: consolidate colored graph cmp logic\n\n t/lib-log-graph.sh           | 28 ++++++++++++\n t/t3430-rebase-merges.sh     |  5 +--\n t/t4202-log.sh               | 57 +++++++------------------\n t/t4214-log-graph-octopus.sh | 82 ++++++++++++------------------------\n t/t4215-log-skewed-merges.sh |  9 ++--\n 5 files changed, 74 insertions(+), 107 deletions(-)\n create mode 100755 t/lib-log-graph.sh\n\n-- \n2.25.0\n\n"},{"id":"392160","messageId":"20200220091528.28472-3-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200220091528.28472-1-abhishekkumar8222@gmail.com","subject":"[PATCH v2 2/2] lib-log-graph: consolidate colored graph cmp logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-20T09:15:28Z","receivedAt":"2020-02-20T09:16:37Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/lib-log-graph.sh           |  6 ++++++\n t/t4202-log.sh               |  4 +---\n t/t4214-log-graph-octopus.sh | 36 ++++++++++++------------------------\n t/t4215-log-skewed-merges.sh |  4 +---\n 4 files changed, 20 insertions(+), 30 deletions(-)\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nindex 97cde44dc7..6185a648ed 100755\n--- a/t/lib-log-graph.sh\n+++ b/t/lib-log-graph.sh\n@@ -20,3 +20,9 @@ lib_test_cmp_short_graph () {\n \tsanitize_log_output >output.sanitized < output &&\n \ttest_i18ncmp expect output.sanitized\n }\n+\n+lib_test_cmp_colored_graph () {\n+\tgit log --graph --color=always \"$@\" >output.colors.raw &&\n+\ttest_decode_color <output.colors.raw | sed \"s/ *\\$//\" >output.colors &&\n+\ttest_cmp expect.colors output.colors\n+}\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex e025a9cfc2..4694b6d0ce 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -537,9 +537,7 @@ EOF\n \n test_expect_success 'log --graph with merge with log.graphColors' '\n \ttest_config log.graphColors \" blue,invalid-color, cyan, red  , \" &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s |\n-\t\ttest_decode_color | sed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect.colors actual\n+\tlib_test_cmp_colored_graph --date-order --format=%s\n '\n \n test_expect_success 'log --raw --graph -m with merge' '\ndiff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh\nindex dedb72ace6..a080325098 100755\n--- a/t/t4214-log-graph-octopus.sh\n+++ b/t/t4214-log-graph-octopus.sh\n@@ -10,6 +10,10 @@ test_cmp_graph () {\n \tlib_test_cmp_graph --color=never --date-order --format=%s \"$@\"\n }\n \n+test_cmp_colored_graph () {\n+\tlib_test_cmp_colored_graph --date-order --format=%s \"$@\"\n+}\n+\n test_expect_success 'set up merge history' '\n \ttest_commit initial &&\n \tfor i in 1 2 3 4 ; do\n@@ -60,9 +64,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph left octopus-merge\n '\n \n # Repeat the previous two tests with \"normal\" octopus merge (i.e.,\n@@ -97,9 +99,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '\n \t* initial\n \tEOF\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph octopus-merge\n '\n \n test_expect_success 'log --graph with normal octopus merge and child, no color' '\n@@ -133,9 +133,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors\n \t* initial\n \tEOF\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-merge\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child, no color' '\n@@ -171,9 +169,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph left after-merge\n '\n \n test_expect_success 'log --graph with crossover in octopus merge, no color' '\n@@ -215,9 +211,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-4 octopus-merge\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '\n@@ -261,9 +255,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-4 after-merge\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '\n@@ -305,9 +297,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-initial octopus-merge\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child, no color' '\n@@ -351,9 +341,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-initial after-merge\n '\n \n test_done\ndiff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\nindex e1e94176da..28d0779a8c 100755\n--- a/t/t4215-log-skewed-merges.sh\n+++ b/t/t4215-log-skewed-merges.sh\n@@ -305,9 +305,7 @@ test_expect_success 'log --graph with multiple tips and colors' '\n \t<BLUE>|<RESET><BLUE>/<RESET>\n \t* 6_A\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\tlib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5\n '\n \n test_expect_success 'log --graph with multiple tips' '\n-- \n2.25.0\n\n"},{"id":"392161","messageId":"20200220091528.28472-2-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200220091528.28472-1-abhishekkumar8222@gmail.com","subject":"[GSoC PATCH v2 1/2] lib-log-graph: consolidate test_cmp_graph logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-20T09:15:27Z","receivedAt":"2020-02-20T09:16:37Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Logic for comparing log graphs is duplicated across test scripts.\n\nThis patch consolidates such logic into lib-log-graph.\n\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/lib-log-graph.sh           | 22 +++++++++++++++\n t/t3430-rebase-merges.sh     |  5 ++--\n t/t4202-log.sh               | 53 ++++++++++--------------------------\n t/t4214-log-graph-octopus.sh | 46 ++++++++++---------------------\n t/t4215-log-skewed-merges.sh |  5 ++--\n 5 files changed, 54 insertions(+), 77 deletions(-)\n create mode 100755 t/lib-log-graph.sh\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nnew file mode 100755\nindex 0000000000..97cde44dc7\n--- /dev/null\n+++ b/t/lib-log-graph.sh\n@@ -0,0 +1,22 @@\n+# Helps shared by the test scripts for comparing log graphs.\n+\n+sanitize_log_output () {\n+\tsed -e 's/ *$//' \\\n+\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n+\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n+\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n+}\n+\n+lib_test_cmp_graph () {\n+\tgit log --graph \"$@\" >output &&\n+\tsed 's/ *$//' >output.sanitized < output &&\n+\ttest_i18ncmp expect output.sanitized\n+}\n+\n+lib_test_cmp_short_graph () {\n+\tgit log --graph --pretty=short \"$@\" >output &&\n+\tsanitize_log_output >output.sanitized < output &&\n+\ttest_i18ncmp expect output.sanitized\n+}\ndiff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh\nindex e72ca348ea..a1bc3e2001 100755\n--- a/t/t3430-rebase-merges.sh\n+++ b/t/t3430-rebase-merges.sh\n@@ -20,12 +20,11 @@ Initial setup:\n '\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-rebase.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n test_cmp_graph () {\n \tcat >expect &&\n-\tgit log --graph --boundary --format=%s \"$@\" >output &&\n-\tsed \"s/ *$//\" <output >output.trimmed &&\n-\ttest_cmp expect output.trimmed\n+\tlib_test_cmp_graph --boundary --format=%s \"$@\"\n }\n \n test_expect_success 'setup' '\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 192347a3e1..e025a9cfc2 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -5,6 +5,11 @@ test_description='git log'\n . ./test-lib.sh\n . \"$TEST_DIRECTORY/lib-gpg.sh\"\n . \"$TEST_DIRECTORY/lib-terminal.sh\"\n+. \"$TEST_DIRECTORY/lib-log-graph.sh\"\n+\n+test_cmp_graph () {\n+\tlib_test_cmp_graph --format=%s \"$@\"\n+}\n \n test_expect_success setup '\n \n@@ -452,8 +457,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph' '\n-\tgit log --graph --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph\n '\n \n cat > expect <<EOF\n@@ -467,8 +471,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph --line-prefix=\"123 \"' '\n-\tgit log --graph --line-prefix=\"123 \" --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --line-prefix=\"123 \"\n '\n \n test_expect_success 'set up merge history' '\n@@ -495,9 +498,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph with merge' '\n-\tgit log --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --date-order\n '\n \n cat > expect <<\\EOF\n@@ -516,9 +517,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph --line-prefix=\"| | | \" with merge' '\n-\tgit log --line-prefix=\"| | | \" --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --line-prefix=\"| | | \" --date-order\n '\n \n cat > expect.colors <<\\EOF\n@@ -676,9 +675,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph with merge' '\n-\tgit log --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --date-order\n '\n \n test_expect_success 'log.decorate configuration' '\n@@ -1213,24 +1210,8 @@ cat >expect <<\\EOF\n   +one\n EOF\n \n-sanitize_output () {\n-\tsed -e 's/ *$//' \\\n-\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n-\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n-\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/, 0 deletions(-)//' \\\n-\t    -e 's/, 0 insertions(+)//' \\\n-\t    -e 's/ 1 files changed, / 1 file changed, /' \\\n-\t    -e 's/, 1 deletions(-)/, 1 deletion(-)/' \\\n-\t    -e 's/, 1 insertions(+)/, 1 insertion(+)/' \\\n-\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n-}\n-\n test_expect_success 'log --graph with diff and stats' '\n-\tgit log --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\tlib_test_cmp_short_graph --no-renames --stat -p\n '\n \n cat >expect <<\\EOF\n@@ -1505,9 +1486,7 @@ cat >expect <<\\EOF\n EOF\n \n test_expect_success 'log --line-prefix=\"*** \" --graph with diff and stats' '\n-\tgit log --line-prefix=\"*** \" --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\tlib_test_cmp_short_graph --line-prefix=\"*** \" --no-renames --stat -p\n '\n \n cat >expect <<-\\EOF\n@@ -1529,9 +1508,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-status' '\n-\tgit log --graph --format=%s --name-status tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph --name-status tangle..reach\n '\n \n cat >expect <<-\\EOF\n@@ -1553,9 +1530,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-only' '\n-\tgit log --graph --format=%s --name-only tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph --name-only tangle..reach\n '\n \n test_expect_success 'dotdot is a parent directory' '\ndiff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh\nindex 40d27db674..dedb72ace6 100755\n--- a/t/t4214-log-graph-octopus.sh\n+++ b/t/t4214-log-graph-octopus.sh\n@@ -3,6 +3,12 @@\n test_description='git log --graph of skewed left octopus merge.'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n+\n+test_cmp_graph () {\n+\tcat >expect &&\n+\tlib_test_cmp_graph --color=never --date-order --format=%s \"$@\"\n+}\n \n test_expect_success 'set up merge history' '\n \ttest_commit initial &&\n@@ -24,7 +30,7 @@ test_expect_success 'set up merge history' '\n '\n \n test_expect_success 'log --graph with tricky octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph left octopus-merge <<-\\EOF\n \t* left\n \t| *-.   octopus-merge\n \t|/|\\ \\\n@@ -37,9 +43,6 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge with colors' '\n@@ -66,7 +69,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n # without the first parent skewing to the \"left\" branch column).\n \n test_expect_success 'log --graph with normal octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph octopus-merge <<-\\EOF\n \t*---.   octopus-merge\n \t|\\ \\ \\\n \t| | | * 4\n@@ -78,9 +81,6 @@ test_expect_success 'log --graph with normal octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus merge with colors' '\n@@ -103,7 +103,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '\n '\n \n test_expect_success 'log --graph with normal octopus merge and child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-merge <<-\\EOF\n \t* after-merge\n \t*---.   octopus-merge\n \t|\\ \\ \\\n@@ -116,9 +116,6 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus and child merge with colors' '\n@@ -142,7 +139,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph left after-merge <<-\\EOF\n \t* left\n \t| * after-merge\n \t| *-.   octopus-merge\n@@ -156,9 +153,6 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child with colors' '\n@@ -183,7 +177,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co\n '\n \n test_expect_success 'log --graph with crossover in octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-4 octopus-merge <<-\\EOF\n \t* after-4\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -200,9 +194,6 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge with colors' '\n@@ -230,7 +221,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-4 after-merge <<-\\EOF\n \t* after-4\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -248,9 +239,6 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '\n@@ -279,7 +267,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-initial octopus-merge <<-\\EOF\n \t* after-initial\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -296,9 +284,6 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '\n@@ -326,7 +311,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-initial after-merge <<-\\EOF\n \t* after-initial\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -344,9 +329,6 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child with colors' '\ndiff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\nindex 1d0d3240ff..e1e94176da 100755\n--- a/t/t4215-log-skewed-merges.sh\n+++ b/t/t4215-log-skewed-merges.sh\n@@ -3,12 +3,11 @@\n test_description='git log --graph of skewed merges'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n check_graph () {\n \tcat >expect &&\n-\tgit log --graph --pretty=tformat:%s \"$@\" >actual.raw &&\n-\tsed \"s/ *$//\" actual.raw >actual &&\n-\ttest_cmp expect actual\n+\tlib_test_cmp_graph --format=%s \"$@\"\n }\n \n test_expect_success 'log --graph with merge fusing with its left and right neighbors' '\n-- \n2.25.0\n\n"},{"id":"392178","messageId":"xmqqsgj5b142.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200220091528.28472-2-abhishekkumar8222@gmail.com","subject":"Re: [GSoC PATCH v2 1/2] lib-log-graph: consolidate test_cmp_graph logic","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-20T17:49:17Z","receivedAt":"2020-02-20T17:49:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Logic for comparing log graphs is duplicated across test scripts.\n>\n> This patch consolidates such logic into lib-log-graph.\n\nThe proposed log message is a bit thin.  It does a bit more than\n\"conslidates\", doesn't it?\n\n> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n> ---\n>  t/lib-log-graph.sh           | 22 +++++++++++++++\n>  t/t3430-rebase-merges.sh     |  5 ++--\n>  t/t4202-log.sh               | 53 ++++++++++--------------------------\n>  t/t4214-log-graph-octopus.sh | 46 ++++++++++---------------------\n>  t/t4215-log-skewed-merges.sh |  5 ++--\n>  5 files changed, 54 insertions(+), 77 deletions(-)\n>  create mode 100755 t/lib-log-graph.sh\n>\n> diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\n> new file mode 100755\n> index 0000000000..97cde44dc7\n> --- /dev/null\n> +++ b/t/lib-log-graph.sh\n> @@ -0,0 +1,22 @@\n> +# Helps shared by the test scripts for comparing log graphs.\n> +\n> +sanitize_log_output () {\n> +\tsed -e 's/ *$//' \\\n> +\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n> +\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n> +\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n> +\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n> +\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n> +}\n\nFor example, discarding the singular/plural compat stuff from the\nt4202's version is OK, but we should record that is what we did in\nthe log message to allow readers to notice.\n\n> +lib_test_cmp_graph () {\n\nNicely named.\n\n> +\tgit log --graph \"$@\" >output &&\n> +\tsed 's/ *$//' >output.sanitized < output &&\n\nLose SP not just on the output redirection but also on the input\nredirection.  I.e.\n\n\tsed 's/ *$//' >output.sanitized <output &&\n\nOr you can lose the input redirection altogether as \"sed\" knows to\ntreat remaining command line arguments as names of its input files,\ni.e.\n\n\tsed 's/ *$//' output >output.sanitized &&\n\nPeople may find the latter easier to read.  I personally do not have\nstrong preference either way as long as it is consistent.\n\n> +\ttest_i18ncmp expect output.sanitized\n> +}\n> +\n> +lib_test_cmp_short_graph () {\n> +\tgit log --graph --pretty=short \"$@\" >output &&\n> +\tsanitize_log_output >output.sanitized < output &&\n\n\tsanitize_log_output <output >output.sanitized &&\n\n(I won't repeat)\n\n\n>  check_graph () {\n>  \tcat >expect &&\n> -\tgit log --graph --pretty=tformat:%s \"$@\" >actual.raw &&\n> -\tsed \"s/ *$//\" actual.raw >actual &&\n> -\ttest_cmp expect actual\n> +\tlib_test_cmp_graph --format=%s \"$@\"\n>  }\n\nHmm, is this correct?  The input goes to expect but the new helper\nyou wrote, lib_test_cmp_graph, won't see it.\n\n"},{"id":"392403","messageId":"20200224133814.100150-1-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200216134750.18947-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch v3 1/2] lib-log-graph: consolidate test_cmp_graph logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-24T13:38:13Z","receivedAt":"2020-02-24T13:39:15Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Log graph comparision logic is duplicated many times in:\n- t3430-rebase-merges.sh\n- t4202-log.sh\n- t4214-log-graph-octopus.sh\n- t4215-log-skewed-merges.sh\n\nThis patch consolidates comparision and sanitization logic in\nlib-log-graph.\n\nReplaces duplicated code with local and lib helpers - making test\nscripts cleaner and more readable.\n\nCloses gitgitgadget issue #471\n\nSigned-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\nChanges in v3:\n- Elaborate on first commit message.\n- Fix SP violations in lib-log-graph.\n\nChanges in v2:\n- Arrange patches by functions changed instead of files changed.\n- Rename library functions by prepending 'lib_'.\n- Drop outdated sanitization calls to sed.\n- Create specialized helpers to reduce code noise.\n- Fix style violations.\n\n t/lib-log-graph.sh           | 22 +++++++++++++++\n t/t3430-rebase-merges.sh     |  5 ++--\n t/t4202-log.sh               | 53 ++++++++++--------------------------\n t/t4214-log-graph-octopus.sh | 46 ++++++++++---------------------\n t/t4215-log-skewed-merges.sh |  5 ++--\n 5 files changed, 54 insertions(+), 77 deletions(-)\n create mode 100755 t/lib-log-graph.sh\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nnew file mode 100755\nindex 0000000000..f9c6526eff\n--- /dev/null\n+++ b/t/lib-log-graph.sh\n@@ -0,0 +1,22 @@\n+# Helps shared by the test scripts for comparing log graphs.\n+\n+sanitize_log_output () {\n+\tsed -e 's/ *$//' \\\n+\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n+\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n+\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n+\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n+}\n+\n+lib_test_cmp_graph () {\n+\tgit log --graph \"$@\" >output &&\n+\tsed 's/ *$//' >output.sanitized <output &&\n+\ttest_i18ncmp expect output.sanitized\n+}\n+\n+lib_test_cmp_short_graph () {\n+\tgit log --graph --pretty=short \"$@\" >output &&\n+\tsanitize_log_output >output.sanitized <output &&\n+\ttest_i18ncmp expect output.sanitized\n+}\ndiff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh\nindex e72ca348ea..a1bc3e2001 100755\n--- a/t/t3430-rebase-merges.sh\n+++ b/t/t3430-rebase-merges.sh\n@@ -20,12 +20,11 @@ Initial setup:\n '\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-rebase.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n test_cmp_graph () {\n \tcat >expect &&\n-\tgit log --graph --boundary --format=%s \"$@\" >output &&\n-\tsed \"s/ *$//\" <output >output.trimmed &&\n-\ttest_cmp expect output.trimmed\n+\tlib_test_cmp_graph --boundary --format=%s \"$@\"\n }\n \n test_expect_success 'setup' '\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 192347a3e1..e025a9cfc2 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -5,6 +5,11 @@ test_description='git log'\n . ./test-lib.sh\n . \"$TEST_DIRECTORY/lib-gpg.sh\"\n . \"$TEST_DIRECTORY/lib-terminal.sh\"\n+. \"$TEST_DIRECTORY/lib-log-graph.sh\"\n+\n+test_cmp_graph () {\n+\tlib_test_cmp_graph --format=%s \"$@\"\n+}\n \n test_expect_success setup '\n \n@@ -452,8 +457,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph' '\n-\tgit log --graph --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph\n '\n \n cat > expect <<EOF\n@@ -467,8 +471,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'simple log --graph --line-prefix=\"123 \"' '\n-\tgit log --graph --line-prefix=\"123 \" --pretty=tformat:%s >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --line-prefix=\"123 \"\n '\n \n test_expect_success 'set up merge history' '\n@@ -495,9 +498,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph with merge' '\n-\tgit log --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --date-order\n '\n \n cat > expect <<\\EOF\n@@ -516,9 +517,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph --line-prefix=\"| | | \" with merge' '\n-\tgit log --line-prefix=\"| | | \" --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --line-prefix=\"| | | \" --date-order\n '\n \n cat > expect.colors <<\\EOF\n@@ -676,9 +675,7 @@ cat > expect <<\\EOF\n EOF\n \n test_expect_success 'log --graph with merge' '\n-\tgit log --graph --date-order --pretty=tformat:%s |\n-\t\tsed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp_graph --date-order\n '\n \n test_expect_success 'log.decorate configuration' '\n@@ -1213,24 +1210,8 @@ cat >expect <<\\EOF\n   +one\n EOF\n \n-sanitize_output () {\n-\tsed -e 's/ *$//' \\\n-\t    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \\\n-\t    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \\\n-\t    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \\\n-\t    -e 's/, 0 deletions(-)//' \\\n-\t    -e 's/, 0 insertions(+)//' \\\n-\t    -e 's/ 1 files changed, / 1 file changed, /' \\\n-\t    -e 's/, 1 deletions(-)/, 1 deletion(-)/' \\\n-\t    -e 's/, 1 insertions(+)/, 1 insertion(+)/' \\\n-\t    -e 's/index [0-9a-f]*\\.\\.[0-9a-f]*/index BEFORE..AFTER/'\n-}\n-\n test_expect_success 'log --graph with diff and stats' '\n-\tgit log --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\tlib_test_cmp_short_graph --no-renames --stat -p\n '\n \n cat >expect <<\\EOF\n@@ -1505,9 +1486,7 @@ cat >expect <<\\EOF\n EOF\n \n test_expect_success 'log --line-prefix=\"*** \" --graph with diff and stats' '\n-\tgit log --line-prefix=\"*** \" --no-renames --graph --pretty=short --stat -p >actual &&\n-\tsanitize_output >actual.sanitized <actual &&\n-\ttest_i18ncmp expect actual.sanitized\n+\tlib_test_cmp_short_graph --line-prefix=\"*** \" --no-renames --stat -p\n '\n \n cat >expect <<-\\EOF\n@@ -1529,9 +1508,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-status' '\n-\tgit log --graph --format=%s --name-status tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph --name-status tangle..reach\n '\n \n cat >expect <<-\\EOF\n@@ -1553,9 +1530,7 @@ cat >expect <<-\\EOF\n EOF\n \n test_expect_success 'log --graph with --name-only' '\n-\tgit log --graph --format=%s --name-only tangle..reach >actual &&\n-\tsanitize_output <actual >actual.sanitized &&\n-\ttest_cmp expect actual.sanitized\n+\ttest_cmp_graph --name-only tangle..reach\n '\n \n test_expect_success 'dotdot is a parent directory' '\ndiff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh\nindex 40d27db674..dedb72ace6 100755\n--- a/t/t4214-log-graph-octopus.sh\n+++ b/t/t4214-log-graph-octopus.sh\n@@ -3,6 +3,12 @@\n test_description='git log --graph of skewed left octopus merge.'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n+\n+test_cmp_graph () {\n+\tcat >expect &&\n+\tlib_test_cmp_graph --color=never --date-order --format=%s \"$@\"\n+}\n \n test_expect_success 'set up merge history' '\n \ttest_commit initial &&\n@@ -24,7 +30,7 @@ test_expect_success 'set up merge history' '\n '\n \n test_expect_success 'log --graph with tricky octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph left octopus-merge <<-\\EOF\n \t* left\n \t| *-.   octopus-merge\n \t|/|\\ \\\n@@ -37,9 +43,6 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge with colors' '\n@@ -66,7 +69,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n # without the first parent skewing to the \"left\" branch column).\n \n test_expect_success 'log --graph with normal octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph octopus-merge <<-\\EOF\n \t*---.   octopus-merge\n \t|\\ \\ \\\n \t| | | * 4\n@@ -78,9 +81,6 @@ test_expect_success 'log --graph with normal octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus merge with colors' '\n@@ -103,7 +103,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '\n '\n \n test_expect_success 'log --graph with normal octopus merge and child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-merge <<-\\EOF\n \t* after-merge\n \t*---.   octopus-merge\n \t|\\ \\ \\\n@@ -116,9 +116,6 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with normal octopus and child merge with colors' '\n@@ -142,7 +139,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph left after-merge <<-\\EOF\n \t* left\n \t| * after-merge\n \t| *-.   octopus-merge\n@@ -156,9 +153,6 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s left after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child with colors' '\n@@ -183,7 +177,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co\n '\n \n test_expect_success 'log --graph with crossover in octopus merge, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-4 octopus-merge <<-\\EOF\n \t* after-4\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -200,9 +194,6 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge with colors' '\n@@ -230,7 +221,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-4 after-merge <<-\\EOF\n \t* after-4\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -248,9 +239,6 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '\n@@ -279,7 +267,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-initial octopus-merge <<-\\EOF\n \t* after-initial\n \t| *---.   octopus-merge\n \t| |\\ \\ \\\n@@ -296,9 +284,6 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '\n@@ -326,7 +311,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child, no color' '\n-\tcat >expect.uncolored <<-\\EOF &&\n+\ttest_cmp_graph after-initial after-merge <<-\\EOF\n \t* after-initial\n \t| * after-merge\n \t| *---.   octopus-merge\n@@ -344,9 +329,6 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col\n \t|/\n \t* initial\n \tEOF\n-\tgit log --color=never --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.raw &&\n-\tsed \"s/ *\\$//\" actual.raw >actual &&\n-\ttest_cmp expect.uncolored actual\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child with colors' '\ndiff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\nindex 1d0d3240ff..e1e94176da 100755\n--- a/t/t4215-log-skewed-merges.sh\n+++ b/t/t4215-log-skewed-merges.sh\n@@ -3,12 +3,11 @@\n test_description='git log --graph of skewed merges'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n \n check_graph () {\n \tcat >expect &&\n-\tgit log --graph --pretty=tformat:%s \"$@\" >actual.raw &&\n-\tsed \"s/ *$//\" actual.raw >actual &&\n-\ttest_cmp expect actual\n+\tlib_test_cmp_graph --format=%s \"$@\"\n }\n \n test_expect_success 'log --graph with merge fusing with its left and right neighbors' '\n-- \n2.25.1\n\n"},{"id":"392404","messageId":"20200224133814.100150-2-abhishekkumar8222@gmail.com","threadId":"52816","inReplyTo":"20200224133814.100150-1-abhishekkumar8222@gmail.com","subject":"[GSoC Patch v3 2/2] lib-log-graph: consolidate colored graph cmp logic","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-24T13:38:14Z","receivedAt":"2020-02-24T13:39:18Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>\n---\n t/lib-log-graph.sh           |  6 ++++++\n t/t4202-log.sh               |  4 +---\n t/t4214-log-graph-octopus.sh | 36 ++++++++++++------------------------\n t/t4215-log-skewed-merges.sh |  4 +---\n 4 files changed, 20 insertions(+), 30 deletions(-)\n\ndiff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh\nindex f9c6526eff..1184cceef2 100755\n--- a/t/lib-log-graph.sh\n+++ b/t/lib-log-graph.sh\n@@ -20,3 +20,9 @@ lib_test_cmp_short_graph () {\n \tsanitize_log_output >output.sanitized <output &&\n \ttest_i18ncmp expect output.sanitized\n }\n+\n+lib_test_cmp_colored_graph () {\n+\tgit log --graph --color=always \"$@\" >output.colors.raw &&\n+\ttest_decode_color <output.colors.raw | sed \"s/ *\\$//\" >output.colors &&\n+\ttest_cmp expect.colors output.colors\n+}\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex e025a9cfc2..4694b6d0ce 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -537,9 +537,7 @@ EOF\n \n test_expect_success 'log --graph with merge with log.graphColors' '\n \ttest_config log.graphColors \" blue,invalid-color, cyan, red  , \" &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s |\n-\t\ttest_decode_color | sed \"s/ *\\$//\" >actual &&\n-\ttest_cmp expect.colors actual\n+\tlib_test_cmp_colored_graph --date-order --format=%s\n '\n \n test_expect_success 'log --raw --graph -m with merge' '\ndiff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh\nindex dedb72ace6..a080325098 100755\n--- a/t/t4214-log-graph-octopus.sh\n+++ b/t/t4214-log-graph-octopus.sh\n@@ -10,6 +10,10 @@ test_cmp_graph () {\n \tlib_test_cmp_graph --color=never --date-order --format=%s \"$@\"\n }\n \n+test_cmp_colored_graph () {\n+\tlib_test_cmp_colored_graph --date-order --format=%s \"$@\"\n+}\n+\n test_expect_success 'set up merge history' '\n \ttest_commit initial &&\n \tfor i in 1 2 3 4 ; do\n@@ -60,9 +64,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph left octopus-merge\n '\n \n # Repeat the previous two tests with \"normal\" octopus merge (i.e.,\n@@ -97,9 +99,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '\n \t* initial\n \tEOF\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph octopus-merge\n '\n \n test_expect_success 'log --graph with normal octopus merge and child, no color' '\n@@ -133,9 +133,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors\n \t* initial\n \tEOF\n \ttest_config log.graphColors red,green,yellow,blue,magenta,cyan &&\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-merge\n '\n \n test_expect_success 'log --graph with tricky octopus merge and its child, no color' '\n@@ -171,9 +169,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph left after-merge\n '\n \n test_expect_success 'log --graph with crossover in octopus merge, no color' '\n@@ -215,9 +211,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '\n \t<MAGENTA>|<RESET><MAGENTA>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-4 octopus-merge\n '\n \n test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '\n@@ -261,9 +255,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w\n \t<CYAN>|<RESET><CYAN>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-4 after-merge\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '\n@@ -305,9 +297,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-initial octopus-merge\n '\n \n test_expect_success 'log --graph with unrelated commit and octopus child, no color' '\n@@ -351,9 +341,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co\n \t<RED>|<RESET><RED>/<RESET>\n \t* initial\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\ttest_cmp_colored_graph after-initial after-merge\n '\n \n test_done\ndiff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh\nindex e1e94176da..28d0779a8c 100755\n--- a/t/t4215-log-skewed-merges.sh\n+++ b/t/t4215-log-skewed-merges.sh\n@@ -305,9 +305,7 @@ test_expect_success 'log --graph with multiple tips and colors' '\n \t<BLUE>|<RESET><BLUE>/<RESET>\n \t* 6_A\n \tEOF\n-\tgit log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&\n-\ttest_decode_color <actual.colors.raw | sed \"s/ *\\$//\" >actual.colors &&\n-\ttest_cmp expect.colors actual.colors\n+\tlib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5\n '\n \n test_expect_success 'log --graph with multiple tips' '\n-- \n2.25.1\n\n"},{"id":"392442","messageId":"xmqqr1yjofc7.fsf@gitster-ct.c.googlers.com","threadId":"52816","inReplyTo":"20200224133814.100150-1-abhishekkumar8222@gmail.com","subject":"Re: [GSoC Patch v3 1/2] lib-log-graph: consolidate test_cmp_graph logic","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-24T21:17:12Z","receivedAt":"2020-02-24T21:17:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n\n> Changes in v3:\n> - Elaborate on first commit message.\n> - Fix SP violations in lib-log-graph.\n>\n> Changes in v2:\n> - Arrange patches by functions changed instead of files changed.\n> - Rename library functions by prepending 'lib_'.\n> - Drop outdated sanitization calls to sed.\n> - Create specialized helpers to reduce code noise.\n> - Fix style violations.\n\nThis round looks quite polished.  I'll queue after massaging the log\nmessage of the first step.\n\nThanks.\n"}]}