{"thread":{"id":"54926","subject":"[PATCH] t6016: move to lib-log-graph.sh framework","startedAt":"2021-01-04T02:35:32Z","lastAt":"2021-01-10T15:29:43Z","messageCount":7,"participants":["Antonio Russo","Abhishek Kumar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"413357","messageId":"6dc37f6b-1afd-544d-126e-2be9422571c6@aerusso.net","threadId":"54926","inReplyTo":null,"subject":"[PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Antonio Russo","fromEmail":"aerusso@aerusso.net","sentAt":"2021-01-04T02:30:35Z","receivedAt":"2021-01-04T02:35:32Z","isPatch":true,"sender":{"key":"aerusso@aerusso.net","avatar":"https://avatars.githubusercontent.com/u/6502699?v=4"},"body":"t6016 manually reconstructs git log --graph output by using the reported\ncommit hashes from `git rev-parse`.  Each tag is converted into an\nenvironment variable manually, and then `echo`-ed to an expected output\nfile, which is in turn compared to the actual output.\n\nThe expected output is difficult to read and write, because, e.g.,\neach line of output must be prefaced with echo, quoted, and properly\nescaped.  Additionally, the test is sensitive to trailing whitespace,\nwhich may potentially be removed from graph log output in the future.\n\nIn order to reduce duplication, ease troubleshooting of failed tests by\nimproving readability, and ease the addition of more tests to this file,\nport the operations to `lib-log-graph.sh`, which is already used in\nseveral other tests, e.g., t4215.  Give all merges a simple commit\nmessage, and use a common `check_graph` macro taking a heredoc of the\nexpected output which does not required extensive escaping.\n\nSigned-off-by: Antonio Russo <aerusso@aerusso.net>\n---\n t/t6016-rev-list-graph-simplify-history.sh | 354 ++++++++++-----------\n 1 file changed, 167 insertions(+), 187 deletions(-)\n\nThis patch builds, and passes the test suite on travis-ci:\n\nhttps://travis-ci.org/github/aerusso/git/builds/752694578\n\ndiff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh\nindex f5e6e92f5b..f79df8b6d1 100755\n--- a/t/t6016-rev-list-graph-simplify-history.sh\n+++ b/t/t6016-rev-list-graph-simplify-history.sh\n@@ -8,6 +8,12 @@\n test_description='--graph and simplified history'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n+\n+check_graph () {\n+\tcat >expect &&\n+\tlib_test_cmp_graph --format=%s \"$@\"\n+}\n \n test_expect_success 'set up rev-list --graph test' '\n \t# 3 commits on branch A\n@@ -28,7 +34,7 @@ test_expect_success 'set up rev-list --graph test' '\n \n \t# Octopus merge B and C into branch A\n \tgit checkout A &&\n-\tgit merge B C &&\n+\tgit merge B C -m A4 &&\n \tgit tag A4 &&\n \n \ttest_commit A5 bar.txt &&\n@@ -38,81 +44,64 @@ test_expect_success 'set up rev-list --graph test' '\n \ttest_commit C3 foo.txt &&\n \ttest_commit C4 bar.txt &&\n \tgit checkout A &&\n-\tgit merge -s ours C &&\n+\tgit merge -s ours C -m A6 &&\n \tgit tag A6 &&\n \n-\ttest_commit A7 bar.txt &&\n-\n-\t# Store commit names in variables for later use\n-\tA1=$(git rev-parse --verify A1) &&\n-\tA2=$(git rev-parse --verify A2) &&\n-\tA3=$(git rev-parse --verify A3) &&\n-\tA4=$(git rev-parse --verify A4) &&\n-\tA5=$(git rev-parse --verify A5) &&\n-\tA6=$(git rev-parse --verify A6) &&\n-\tA7=$(git rev-parse --verify A7) &&\n-\tB1=$(git rev-parse --verify B1) &&\n-\tB2=$(git rev-parse --verify B2) &&\n-\tC1=$(git rev-parse --verify C1) &&\n-\tC2=$(git rev-parse --verify C2) &&\n-\tC3=$(git rev-parse --verify C3) &&\n-\tC4=$(git rev-parse --verify C4)\n-\t'\n+\ttest_commit A7 bar.txt\n+'\n \n test_expect_success '--graph --all' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |   \" >> expected &&\n-\techo \"|  \\\\  \" >> expected &&\n-\techo \"*-. | $A4\" >> expected &&\n-\techo \"|\\\\ \\\\| \" >> expected &&\n-\techo \"| | * $C2\" >> expected &&\n-\techo \"| | * $C1\" >> expected &&\n-\techo \"| * | $B2\" >> expected &&\n-\techo \"| * | $B1\" >> expected &&\n-\techo \"* | | $A3\" >> expected &&\n-\techo \"| |/  \" >> expected &&\n-\techo \"|/|   \" >> expected &&\n-\techo \"* | $A2\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --all > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. | A4\n+\t|\\ \\|\n+\t| | * C2\n+\t| | * C1\n+\t| * | B2\n+\t| * | B1\n+\t* | | A3\n+\t| |/\n+\t|/|\n+\t* | A2\n+\t|/\n+\t* A1\n+\tEOF\n+'\n \n # Make sure the graph_is_interesting() code still realizes\n # that undecorated merges are interesting, even with --simplify-by-decoration\n test_expect_success '--graph --simplify-by-decoration' '\n-\trm -f expected &&\n \tgit tag -d A4 &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |   \" >> expected &&\n-\techo \"|  \\\\  \" >> expected &&\n-\techo \"*-. | $A4\" >> expected &&\n-\techo \"|\\\\ \\\\| \" >> expected &&\n-\techo \"| | * $C2\" >> expected &&\n-\techo \"| | * $C1\" >> expected &&\n-\techo \"| * | $B2\" >> expected &&\n-\techo \"| * | $B1\" >> expected &&\n-\techo \"* | | $A3\" >> expected &&\n-\techo \"| |/  \" >> expected &&\n-\techo \"|/|   \" >> expected &&\n-\techo \"* | $A2\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --all --simplify-by-decoration > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all --simplify-by-decoration <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. | A4\n+\t|\\ \\|\n+\t| | * C2\n+\t| | * C1\n+\t| * | B2\n+\t| * | B1\n+\t* | | A3\n+\t| |/\n+\t|/|\n+\t* | A2\n+\t|/\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success 'setup: get rid of decorations on B' '\n \tgit tag -d B2 &&\n@@ -122,142 +111,133 @@ test_expect_success 'setup: get rid of decorations on B' '\n \n # Graph with branch B simplified away\n test_expect_success '--graph --simplify-by-decoration prune branch B' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A4\" >> expected &&\n-\techo \"|\\\\| \" >> expected &&\n-\techo \"| * $C2\" >> expected &&\n-\techo \"| * $C1\" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --simplify-by-decoration --all > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --simplify-by-decoration --all <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t* | A4\n+\t|\\|\n+\t| * C2\n+\t| * C1\n+\t* | A3\n+\t|/\n+\t* A2\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success '--graph --full-history -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A4\" >> expected &&\n-\techo \"|\\\\| \" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --full-history --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --full-history --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t* | A4\n+\t|\\|\n+\t* | A3\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --full-history --simplify-merges --all \\\n-\t\t-- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --full-history --simplify-merges --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t* | A3\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t* A5\n+\t* A3\n+\t| * C4\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph --sparse -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A6\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"* $A4\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"| * $C2\" >> expected &&\n-\techo \"| * $C1\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --sparse --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --sparse --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t* A6\n+\t* A5\n+\t* A4\n+\t* A3\n+\t| * C4\n+\t| * C3\n+\t| * C2\n+\t| * C1\n+\t|/\n+\t* A2\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success '--graph ^C4' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A6\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"*   $A4\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $B2\" >> expected &&\n-\techo \"| * $B1\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\tgit rev-list --graph --all ^C4 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all ^C4 <<-\\EOF\n+\t* A7\n+\t* A6\n+\t* A5\n+\t*   A4\n+\t|\\\n+\t| * B2\n+\t| * B1\n+\t* A3\n+\tEOF\n+'\n \n test_expect_success '--graph ^C3' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"*   $A4\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $B2\" >> expected &&\n-\techo \"| * $B1\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\tgit rev-list --graph --all ^C3 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all ^C3 <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* A5\n+\t*   A4\n+\t|\\\n+\t| * B2\n+\t| * B1\n+\t* A3\n+\tEOF\n+'\n \n # I don't think the ordering of the boundary commits is really\n # that important, but this test depends on it.  If the ordering ever changes\n # in the code, we'll need to update this test.\n test_expect_success '--graph --boundary ^C3' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |     \" >> expected &&\n-\techo \"|  \\\\    \" >> expected &&\n-\techo \"*-. \\\\   $A4\" >> expected &&\n-\techo \"|\\\\ \\\\ \\\\  \" >> expected &&\n-\techo \"| * | | $B2\" >> expected &&\n-\techo \"| * | | $B1\" >> expected &&\n-\techo \"* | | | $A3\" >> expected &&\n-\techo \"o | | | $A2\" >> expected &&\n-\techo \"|/ / /  \" >> expected &&\n-\techo \"o / / $A1\" >> expected &&\n-\techo \" / /  \" >> expected &&\n-\techo \"| o $C3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"o $C2\" >> expected &&\n-\tgit rev-list --graph --boundary --all ^C3 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --boundary --all ^C3 <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. \\   A4\n+\t|\\ \\ \\\n+\t| * | | B2\n+\t| * | | B1\n+\t* | | | A3\n+\to | | | A2\n+\t|/ / /\n+\to / / A1\n+\t / /\n+\t| o C3\n+\t|/\n+\to C2\n+\tEOF\n+'\n \n test_done\n-- \n2.30.0\n"},{"id":"413370","messageId":"X/K1BgP8tpsgNe2x@Abhishek-Arch","threadId":"54926","inReplyTo":"6dc37f6b-1afd-544d-126e-2be9422571c6@aerusso.net","subject":"Re: [PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2021-01-04T06:26:14Z","receivedAt":"2021-01-04T06:26:56Z","isPatch":true,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"On Sun, Jan 03, 2021 at 07:30:35PM -0700, Antonio Russo wrote:\n> t6016 manually reconstructs git log --graph output by using the reported\n> commit hashes from `git rev-parse`.  Each tag is converted into an\n> environment variable manually, and then `echo`-ed to an expected output\n> file, which is in turn compared to the actual output.\n> \n> The expected output is difficult to read and write, because, e.g.,\n> each line of output must be prefaced with echo, quoted, and properly\n> escaped.  Additionally, the test is sensitive to trailing whitespace,\n> which may potentially be removed from graph log output in the future.\n> \n> In order to reduce duplication, ease troubleshooting of failed tests by\n> improving readability, and ease the addition of more tests to this file,\n> port the operations to `lib-log-graph.sh`, which is already used in\n> several other tests, e.g., t4215.  Give all merges a simple commit\n> message, and use a common `check_graph` macro taking a heredoc of the\n> expected output which does not required extensive escaping.\n> \n\nGlad to see others using `lib-log-graph.sh` as well!\n\nThe changes look alright to me but maybe you could have split the two\nchanges into two different commits: Using tags directly instead of\nenvironment variables and using `check_graph` instead of manually\n`echo`-ing to an expected output and comparing with the actual output.\n\nOther contributors would have a better idea whether it's truly required\nor not.\n\n> Signed-off-by: Antonio Russo <aerusso@aerusso.net>\n> ---\n>  t/t6016-rev-list-graph-simplify-history.sh | 354 ++++++++++-----------\n>  1 file changed, 167 insertions(+), 187 deletions(-)\n> \n> This patch builds, and passes the test suite on travis-ci:\n> \n> https://travis-ci.org/github/aerusso/git/builds/752694578\n> \n> diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh\n> index f5e6e92f5b..f79df8b6d1 100755\n> --- a/t/t6016-rev-list-graph-simplify-history.sh\n> +++ b/t/t6016-rev-list-graph-simplify-history.sh\n> @@ -8,6 +8,12 @@\n>  test_description='--graph and simplified history'\n>  \n>  . ./test-lib.sh\n> +. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n> +\n> +check_graph () {\n> +\tcat >expect &&\n> +\tlib_test_cmp_graph --format=%s \"$@\"\n> +}\n>  \n>  test_expect_success 'set up rev-list --graph test' '\n>  \t# 3 commits on branch A\n> @@ -28,7 +34,7 @@ test_expect_success 'set up rev-list --graph test' '\n>  \n>  \t# Octopus merge B and C into branch A\n>  \tgit checkout A &&\n> -\tgit merge B C &&\n> +\tgit merge B C -m A4 &&\n>  \tgit tag A4 &&\n>  \n>  \ttest_commit A5 bar.txt &&\n> @@ -38,81 +44,64 @@ test_expect_success 'set up rev-list --graph test' '\n>  \ttest_commit C3 foo.txt &&\n>  \ttest_commit C4 bar.txt &&\n>  \tgit checkout A &&\n> -\tgit merge -s ours C &&\n> +\tgit merge -s ours C -m A6 &&\n>  \tgit tag A6 &&\n>  \n> -\ttest_commit A7 bar.txt &&\n> -\n> -\t# Store commit names in variables for later use\n> -\tA1=$(git rev-parse --verify A1) &&\n> -\tA2=$(git rev-parse --verify A2) &&\n> -\tA3=$(git rev-parse --verify A3) &&\n> -\tA4=$(git rev-parse --verify A4) &&\n> -\tA5=$(git rev-parse --verify A5) &&\n> -\tA6=$(git rev-parse --verify A6) &&\n> -\tA7=$(git rev-parse --verify A7) &&\n> -\tB1=$(git rev-parse --verify B1) &&\n> -\tB2=$(git rev-parse --verify B2) &&\n> -\tC1=$(git rev-parse --verify C1) &&\n> -\tC2=$(git rev-parse --verify C2) &&\n> -\tC3=$(git rev-parse --verify C3) &&\n> -\tC4=$(git rev-parse --verify C4)\n> -\t'\n> +\ttest_commit A7 bar.txt\n> +'\n>  \n>  test_expect_success '--graph --all' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"| * $C3\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"| |   \" >> expected &&\n> -\techo \"|  \\\\  \" >> expected &&\n> -\techo \"*-. | $A4\" >> expected &&\n> -\techo \"|\\\\ \\\\| \" >> expected &&\n> -\techo \"| | * $C2\" >> expected &&\n> -\techo \"| | * $C1\" >> expected &&\n> -\techo \"| * | $B2\" >> expected &&\n> -\techo \"| * | $B1\" >> expected &&\n> -\techo \"* | | $A3\" >> expected &&\n> -\techo \"| |/  \" >> expected &&\n> -\techo \"|/|   \" >> expected &&\n> -\techo \"* | $A2\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A1\" >> expected &&\n> -\tgit rev-list --graph --all > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --all <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t| * C3\n> +\t* | A5\n> +\t| |\n> +\t|  \\\n> +\t*-. | A4\n> +\t|\\ \\|\n> +\t| | * C2\n> +\t| | * C1\n> +\t| * | B2\n> +\t| * | B1\n> +\t* | | A3\n> +\t| |/\n> +\t|/|\n> +\t* | A2\n> +\t|/\n> +\t* A1\n> +\tEOF\n> +'\n>  \n>  # Make sure the graph_is_interesting() code still realizes\n>  # that undecorated merges are interesting, even with --simplify-by-decoration\n>  test_expect_success '--graph --simplify-by-decoration' '\n> -\trm -f expected &&\n>  \tgit tag -d A4 &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"| * $C3\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"| |   \" >> expected &&\n> -\techo \"|  \\\\  \" >> expected &&\n> -\techo \"*-. | $A4\" >> expected &&\n> -\techo \"|\\\\ \\\\| \" >> expected &&\n> -\techo \"| | * $C2\" >> expected &&\n> -\techo \"| | * $C1\" >> expected &&\n> -\techo \"| * | $B2\" >> expected &&\n> -\techo \"| * | $B1\" >> expected &&\n> -\techo \"* | | $A3\" >> expected &&\n> -\techo \"| |/  \" >> expected &&\n> -\techo \"|/|   \" >> expected &&\n> -\techo \"* | $A2\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A1\" >> expected &&\n> -\tgit rev-list --graph --all --simplify-by-decoration > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --all --simplify-by-decoration <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t| * C3\n> +\t* | A5\n> +\t| |\n> +\t|  \\\n> +\t*-. | A4\n> +\t|\\ \\|\n> +\t| | * C2\n> +\t| | * C1\n> +\t| * | B2\n> +\t| * | B1\n> +\t* | | A3\n> +\t| |/\n> +\t|/|\n> +\t* | A2\n> +\t|/\n> +\t* A1\n> +\tEOF\n> +'\n>  \n>  test_expect_success 'setup: get rid of decorations on B' '\n>  \tgit tag -d B2 &&\n> @@ -122,142 +111,133 @@ test_expect_success 'setup: get rid of decorations on B' '\n>  \n>  # Graph with branch B simplified away\n>  test_expect_success '--graph --simplify-by-decoration prune branch B' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"| * $C3\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"* | $A4\" >> expected &&\n> -\techo \"|\\\\| \" >> expected &&\n> -\techo \"| * $C2\" >> expected &&\n> -\techo \"| * $C1\" >> expected &&\n> -\techo \"* | $A3\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A2\" >> expected &&\n> -\techo \"* $A1\" >> expected &&\n> -\tgit rev-list --graph --simplify-by-decoration --all > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --simplify-by-decoration --all <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t| * C3\n> +\t* | A5\n> +\t* | A4\n> +\t|\\|\n> +\t| * C2\n> +\t| * C1\n> +\t* | A3\n> +\t|/\n> +\t* A2\n> +\t* A1\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph --full-history -- bar.txt' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"* | $A4\" >> expected &&\n> -\techo \"|\\\\| \" >> expected &&\n> -\techo \"* | $A3\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A2\" >> expected &&\n> -\tgit rev-list --graph --full-history --all -- bar.txt > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --full-history --all -- bar.txt <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t* | A5\n> +\t* | A4\n> +\t|\\|\n> +\t* | A3\n> +\t|/\n> +\t* A2\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"* | $A3\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A2\" >> expected &&\n> -\tgit rev-list --graph --full-history --simplify-merges --all \\\n> -\t\t-- bar.txt > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --full-history --simplify-merges --all -- bar.txt <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t* | A5\n> +\t* | A3\n> +\t|/\n> +\t* A2\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph -- bar.txt' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"* $A5\" >> expected &&\n> -\techo \"* $A3\" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A2\" >> expected &&\n> -\tgit rev-list --graph --all -- bar.txt > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --all -- bar.txt <<-\\EOF\n> +\t* A7\n> +\t* A5\n> +\t* A3\n> +\t| * C4\n> +\t|/\n> +\t* A2\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph --sparse -- bar.txt' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"* $A6\" >> expected &&\n> -\techo \"* $A5\" >> expected &&\n> -\techo \"* $A4\" >> expected &&\n> -\techo \"* $A3\" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"| * $C3\" >> expected &&\n> -\techo \"| * $C2\" >> expected &&\n> -\techo \"| * $C1\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"* $A2\" >> expected &&\n> -\techo \"* $A1\" >> expected &&\n> -\tgit rev-list --graph --sparse --all -- bar.txt > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --sparse --all -- bar.txt <<-\\EOF\n> +\t* A7\n> +\t* A6\n> +\t* A5\n> +\t* A4\n> +\t* A3\n> +\t| * C4\n> +\t| * C3\n> +\t| * C2\n> +\t| * C1\n> +\t|/\n> +\t* A2\n> +\t* A1\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph ^C4' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"* $A6\" >> expected &&\n> -\techo \"* $A5\" >> expected &&\n> -\techo \"*   $A4\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $B2\" >> expected &&\n> -\techo \"| * $B1\" >> expected &&\n> -\techo \"* $A3\" >> expected &&\n> -\tgit rev-list --graph --all ^C4 > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --all ^C4 <<-\\EOF\n> +\t* A7\n> +\t* A6\n> +\t* A5\n> +\t*   A4\n> +\t|\\\n> +\t| * B2\n> +\t| * B1\n> +\t* A3\n> +\tEOF\n> +'\n>  \n>  test_expect_success '--graph ^C3' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"* $A5\" >> expected &&\n> -\techo \"*   $A4\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $B2\" >> expected &&\n> -\techo \"| * $B1\" >> expected &&\n> -\techo \"* $A3\" >> expected &&\n> -\tgit rev-list --graph --all ^C3 > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --all ^C3 <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t* A5\n> +\t*   A4\n> +\t|\\\n> +\t| * B2\n> +\t| * B1\n> +\t* A3\n> +\tEOF\n> +'\n>  \n>  # I don't think the ordering of the boundary commits is really\n>  # that important, but this test depends on it.  If the ordering ever changes\n>  # in the code, we'll need to update this test.\n>  test_expect_success '--graph --boundary ^C3' '\n> -\trm -f expected &&\n> -\techo \"* $A7\" >> expected &&\n> -\techo \"*   $A6\" >> expected &&\n> -\techo \"|\\\\  \" >> expected &&\n> -\techo \"| * $C4\" >> expected &&\n> -\techo \"* | $A5\" >> expected &&\n> -\techo \"| |     \" >> expected &&\n> -\techo \"|  \\\\    \" >> expected &&\n> -\techo \"*-. \\\\   $A4\" >> expected &&\n> -\techo \"|\\\\ \\\\ \\\\  \" >> expected &&\n> -\techo \"| * | | $B2\" >> expected &&\n> -\techo \"| * | | $B1\" >> expected &&\n> -\techo \"* | | | $A3\" >> expected &&\n> -\techo \"o | | | $A2\" >> expected &&\n> -\techo \"|/ / /  \" >> expected &&\n> -\techo \"o / / $A1\" >> expected &&\n> -\techo \" / /  \" >> expected &&\n> -\techo \"| o $C3\" >> expected &&\n> -\techo \"|/  \" >> expected &&\n> -\techo \"o $C2\" >> expected &&\n> -\tgit rev-list --graph --boundary --all ^C3 > actual &&\n> -\ttest_cmp expected actual\n> -\t'\n> +\tcheck_graph --boundary --all ^C3 <<-\\EOF\n> +\t* A7\n> +\t*   A6\n> +\t|\\\n> +\t| * C4\n> +\t* | A5\n> +\t| |\n> +\t|  \\\n> +\t*-. \\   A4\n> +\t|\\ \\ \\\n> +\t| * | | B2\n> +\t| * | | B1\n> +\t* | | | A3\n> +\to | | | A2\n> +\t|/ / /\n> +\to / / A1\n> +\t / /\n> +\t| o C3\n> +\t|/\n> +\to C2\n> +\tEOF\n> +'\n>  \n>  test_done\n> -- \n> 2.30.0\n\nThanks\n- Abhishek\n"},{"id":"413414","messageId":"b147caf4-de4c-dc2c-ec3d-6efd611becf5@aerusso.net","threadId":"54926","inReplyTo":"X/K1BgP8tpsgNe2x@Abhishek-Arch","subject":"Re: [PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Antonio Russo","fromEmail":"aerusso@aerusso.net","sentAt":"2021-01-05T00:59:14Z","receivedAt":"2021-01-05T01:00:15Z","isPatch":true,"sender":{"key":"aerusso@aerusso.net","avatar":"https://avatars.githubusercontent.com/u/6502699?v=4"},"body":"On 1/3/21 11:26 PM, Abhishek Kumar wrote:\n> \n> Glad to see others using `lib-log-graph.sh` as well!\n> \n> The changes look alright to me but maybe you could have split the two\n> changes into two different commits: Using tags directly instead of\n> environment variables and using `check_graph` instead of manually\n> `echo`-ing to an expected output and comparing with the actual output.\n> \n> Other contributors would have a better idea whether it's truly required\n> or not.\n> \n\nThanks for the feedback!  I can split this patch in two if that's desired.\n\n[snip]\n\n> \n> Thanks\n> - Abhishek\n> \n\nBest,\nAntonio\n"},{"id":"413528","messageId":"xmqq1reywt7x.fsf@gitster.c.googlers.com","threadId":"54926","inReplyTo":"X/K1BgP8tpsgNe2x@Abhishek-Arch","subject":"Re: [PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-06T05:05:22Z","receivedAt":"2021-01-06T05:06: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> On Sun, Jan 03, 2021 at 07:30:35PM -0700, Antonio Russo wrote:\n>> t6016 manually reconstructs git log --graph output by using the reported\n>> commit hashes from `git rev-parse`.  Each tag is converted into an\n>> environment variable manually, and then `echo`-ed to an expected output\n>> file, which is in turn compared to the actual output.\n>> \n>> The expected output is difficult to read and write, because, e.g.,\n>> each line of output must be prefaced with echo, quoted, and properly\n>> escaped.  Additionally, the test is sensitive to trailing whitespace,\n>> which may potentially be removed from graph log output in the future.\n>> \n>> In order to reduce duplication, ease troubleshooting of failed tests by\n>> improving readability, and ease the addition of more tests to this file,\n>> port the operations to `lib-log-graph.sh`, which is already used in\n>> several other tests, e.g., t4215.  Give all merges a simple commit\n>> message, and use a common `check_graph` macro taking a heredoc of the\n>> expected output which does not required extensive escaping.\n>> \n>\n> Glad to see others using `lib-log-graph.sh` as well!\n>\n> The changes look alright to me but maybe you could have split the two\n> changes into two different commits: Using tags directly instead of\n> environment variables and using `check_graph` instead of manually\n> `echo`-ing to an expected output and comparing with the actual output.\n\nPerhaps.  Also I am wondering if the tests still need to create tags\nafter this change---isn't the output all matched by the commit title\nnow?\n\nThat is ...\n\n>>  . ./test-lib.sh\n>> +. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n>> +\n>> +check_graph () {\n>> +\tcat >expect &&\n>> +\tlib_test_cmp_graph --format=%s \"$@\"\n>> +}\n\n... this only shows the title, and ...\n\n>> -\tgit merge B C &&\n>> +\tgit merge B C -m A4 &&\n\n... that is why we need to have the title here.\n\n>>  \tgit tag A4 &&\n\nNow, does this A4 used anywhere?\n\n>> -\t# Store commit names in variables for later use\n>> -\tA1=$(git rev-parse --verify A1) &&\n>> -\tA2=$(git rev-parse --verify A2) &&\n>> -\tA3=$(git rev-parse --verify A3) &&\n>> -\tA4=$(git rev-parse --verify A4) &&\n\nIt certainly used to be needed here, but ...\n>> +\tcheck_graph --all <<-\\EOF\n>> +\t* A7\n>> +\t*   A6\n>> +\t|\\\n>> +\t| * C4\n>> +\t| * C3\n>> +\t* | A5\n>> +\t| |\n>> +\t|  \\\n>> +\t*-. | A4\n\n... not anymore in the new version.\n\n>> +\t|\\ \\|\n>> +\t| | * C2\n>> +\t| | * C1\n>> +\t| * | B2\n>> +\t| * | B1\n>> +\t* | | A3\n>> +\t| |/\n>> +\t|/|\n>> +\t* | A2\n>> +\t|/\n>> +\t* A1\n>> +\tEOF\n>> +'\n>>  \n"},{"id":"413584","messageId":"d01e2830-d579-67c6-1076-ed44cff27ad7@aerusso.net","threadId":"54926","inReplyTo":"xmqq1reywt7x.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Antonio Russo","fromEmail":"aerusso@aerusso.net","sentAt":"2021-01-06T15:21:01Z","receivedAt":"2021-01-06T15:22:20Z","isPatch":true,"sender":{"key":"aerusso@aerusso.net","avatar":"https://avatars.githubusercontent.com/u/6502699?v=4"},"body":"On 1/5/21 10:05 PM, Junio C Hamano wrote:\n> Abhishek Kumar <abhishekkumar8222@gmail.com> writes:\n> \n>> On Sun, Jan 03, 2021 at 07:30:35PM -0700, Antonio Russo wrote:\n>>> t6016 manually reconstructs git log --graph output by using the reported\n>>> commit hashes from `git rev-parse`.  Each tag is converted into an\n>>> environment variable manually, and then `echo`-ed to an expected output\n>>> file, which is in turn compared to the actual output.\n>>>\n>>> The expected output is difficult to read and write, because, e.g.,\n>>> each line of output must be prefaced with echo, quoted, and properly\n>>> escaped.  Additionally, the test is sensitive to trailing whitespace,\n>>> which may potentially be removed from graph log output in the future.\n>>>\n>>> In order to reduce duplication, ease troubleshooting of failed tests by\n>>> improving readability, and ease the addition of more tests to this file,\n>>> port the operations to `lib-log-graph.sh`, which is already used in\n>>> several other tests, e.g., t4215.  Give all merges a simple commit\n>>> message, and use a common `check_graph` macro taking a heredoc of the\n>>> expected output which does not required extensive escaping.\n>>>\n>>\n>> Glad to see others using `lib-log-graph.sh` as well!\n>>\n>> The changes look alright to me but maybe you could have split the two\n>> changes into two different commits: Using tags directly instead of\n>> environment variables and using `check_graph` instead of manually\n>> `echo`-ing to an expected output and comparing with the actual output.\n> \n> Perhaps.  Also I am wondering if the tests still need to create tags\n> after this change---isn't the output all matched by the commit title\n> now?\n\nYou are correct that the A4 and A6 tags can be removed without affecting\nthe output.  In fact, A4 is basically immediately deleted (in the second test).\nI can remove that, if we want to stop testing the tag deletion logic here.\nI suppose that is sufficiently validated elsewhere in the test suite.\n\nThere's a (weak IMO) argument to keep the A6 tag, since it might in principle\naffect the output at later stages, since it is not deleted and calls are made\nwith --simplify-by-decoration.  Of course, it isn't needed in order to be\ndisplayed, so we're only testing that that the merge commit A6 shows up when\nit *has* a tag, and --simplify-by-decoration is used.  That failure mode\ncertainly seems perverse!\n\nMy guiding principle when I made this patch was to be as minimally invasive\nas possible, while allowing modifications to this file to be pleasant---which\nI must admit is my ulterior motive.\n\nI can certainly remove these \"extraneous\" tags if desired.\n\nBest,\nAntonio\n\n\n> That is ...\n> \n>>>  . ./test-lib.sh\n>>> +. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n>>> +\n>>> +check_graph () {\n>>> +\tcat >expect &&\n>>> +\tlib_test_cmp_graph --format=%s \"$@\"\n>>> +}\n> \n> ... this only shows the title, and ...\n> \n>>> -\tgit merge B C &&\n>>> +\tgit merge B C -m A4 &&\n> \n> ... that is why we need to have the title here.\n> \n>>>  \tgit tag A4 &&\n> \n> Now, does this A4 used anywhere?\n> \n>>> -\t# Store commit names in variables for later use\n>>> -\tA1=$(git rev-parse --verify A1) &&\n>>> -\tA2=$(git rev-parse --verify A2) &&\n>>> -\tA3=$(git rev-parse --verify A3) &&\n>>> -\tA4=$(git rev-parse --verify A4) &&\n> \n> It certainly used to be needed here, but ...\n>>> +\tcheck_graph --all <<-\\EOF\n>>> +\t* A7\n>>> +\t*   A6\n>>> +\t|\\\n>>> +\t| * C4\n>>> +\t| * C3\n>>> +\t* | A5\n>>> +\t| |\n>>> +\t|  \\\n>>> +\t*-. | A4\n> \n> ... not anymore in the new version.\n> \n>>> +\t|\\ \\|\n>>> +\t| | * C2\n>>> +\t| | * C1\n>>> +\t| * | B2\n>>> +\t| * | B1\n>>> +\t* | | A3\n>>> +\t| |/\n>>> +\t|/|\n>>> +\t* | A2\n>>> +\t|/\n>>> +\t* A1\n>>> +\tEOF\n>>> +'\n>>>  \n"},{"id":"413604","messageId":"xmqqlfd5rdja.fsf@gitster.c.googlers.com","threadId":"54926","inReplyTo":"d01e2830-d579-67c6-1076-ed44cff27ad7@aerusso.net","subject":"Re: [PATCH] t6016: move to lib-log-graph.sh framework","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-06T20:55:21Z","receivedAt":"2021-01-06T20:56:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Antonio Russo <aerusso@aerusso.net> writes:\n\n> You are correct that the A4 and A6 tags can be removed without affecting\n> the output.  In fact, A4 is basically immediately deleted (in the second test).\n> I can remove that, if we want to stop testing the tag deletion logic here.\n> I suppose that is sufficiently validated elsewhere in the test suite.\n>\n> There's a (weak IMO) argument to keep the A6 tag, since ...\n\nI see.  Thanks for explaining.\n\n> My guiding principle when I made this patch was to be as minimally invasive\n> as possible, while allowing modifications to this file to be pleasant---which\n> I must admit is my ulterior motive.\n>\n> I can certainly remove these \"extraneous\" tags if desired.\n\nI actually am _for_ keeping these tags.  It is just that I want to\nsee the reason why these tags, some of which are no longer needed\nfor the purpose of matching the output with expectation, are kept\nexplained in the proposed log message.\n\nThanks.\n"},{"id":"413974","messageId":"82785993-0393-4db0-a089-d1633e5d1374@aerusso.net","threadId":"54926","inReplyTo":"6dc37f6b-1afd-544d-126e-2be9422571c6@aerusso.net","subject":"[PATCH v2] t6016: move to lib-log-graph.sh framework","fromName":"Antonio Russo","fromEmail":"aerusso@aerusso.net","sentAt":"2021-01-10T15:28:22Z","receivedAt":"2021-01-10T15:29:43Z","isPatch":true,"sender":{"key":"aerusso@aerusso.net","avatar":"https://avatars.githubusercontent.com/u/6502699?v=4"},"body":"t6016 manually reconstructs git log --graph output by using the reported\ncommit hashes from `git rev-parse`.  Each tag is converted into an\nenvironment variable manually, and then `echo`-ed to an expected output\nfile, which is in turn compared to the actual output.\n\nThe expected output is difficult to read and write, because, e.g.,\neach line of output must be prefaced with echo, quoted, and properly\nescaped.  Additionally, the test is sensitive to trailing whitespace,\nwhich may potentially be removed from graph log output in the future.\n\nIn order to reduce duplication, ease troubleshooting of failed tests by\nimproving readability, and ease the addition of more tests to this file,\nport the operations to `lib-log-graph.sh`, which is already used in\nseveral other tests, e.g., t4215.  Give all merges a simple commit\nmessage, and use a common `check_graph` macro taking a heredoc of the\nexpected output which does not required extensive escaping.\n\nAll commits, including merges, continue to be tagged, even if they are\nimmediately deleted, in order to exercise the exact same logic, i.e. in\n`--all`, `--simplify-by-decoration`, and `git tag -d`.\n\nSigned-off-by: Antonio Russo <aerusso@aerusso.net>\n---\n t/t6016-rev-list-graph-simplify-history.sh | 354 ++++++++++-----------\n 1 file changed, 167 insertions(+), 187 deletions(-)\n\nI did not try to factor this commit into two since I did not hear any\nstrong opinions in favor of that.\n\ndiff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh\nindex f5e6e92f5b..f79df8b6d1 100755\n--- a/t/t6016-rev-list-graph-simplify-history.sh\n+++ b/t/t6016-rev-list-graph-simplify-history.sh\n@@ -8,6 +8,12 @@\n test_description='--graph and simplified history'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-log-graph.sh\n+\n+check_graph () {\n+\tcat >expect &&\n+\tlib_test_cmp_graph --format=%s \"$@\"\n+}\n \n test_expect_success 'set up rev-list --graph test' '\n \t# 3 commits on branch A\n@@ -28,7 +34,7 @@ test_expect_success 'set up rev-list --graph test' '\n \n \t# Octopus merge B and C into branch A\n \tgit checkout A &&\n-\tgit merge B C &&\n+\tgit merge B C -m A4 &&\n \tgit tag A4 &&\n \n \ttest_commit A5 bar.txt &&\n@@ -38,81 +44,64 @@ test_expect_success 'set up rev-list --graph test' '\n \ttest_commit C3 foo.txt &&\n \ttest_commit C4 bar.txt &&\n \tgit checkout A &&\n-\tgit merge -s ours C &&\n+\tgit merge -s ours C -m A6 &&\n \tgit tag A6 &&\n \n-\ttest_commit A7 bar.txt &&\n-\n-\t# Store commit names in variables for later use\n-\tA1=$(git rev-parse --verify A1) &&\n-\tA2=$(git rev-parse --verify A2) &&\n-\tA3=$(git rev-parse --verify A3) &&\n-\tA4=$(git rev-parse --verify A4) &&\n-\tA5=$(git rev-parse --verify A5) &&\n-\tA6=$(git rev-parse --verify A6) &&\n-\tA7=$(git rev-parse --verify A7) &&\n-\tB1=$(git rev-parse --verify B1) &&\n-\tB2=$(git rev-parse --verify B2) &&\n-\tC1=$(git rev-parse --verify C1) &&\n-\tC2=$(git rev-parse --verify C2) &&\n-\tC3=$(git rev-parse --verify C3) &&\n-\tC4=$(git rev-parse --verify C4)\n-\t'\n+\ttest_commit A7 bar.txt\n+'\n \n test_expect_success '--graph --all' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |   \" >> expected &&\n-\techo \"|  \\\\  \" >> expected &&\n-\techo \"*-. | $A4\" >> expected &&\n-\techo \"|\\\\ \\\\| \" >> expected &&\n-\techo \"| | * $C2\" >> expected &&\n-\techo \"| | * $C1\" >> expected &&\n-\techo \"| * | $B2\" >> expected &&\n-\techo \"| * | $B1\" >> expected &&\n-\techo \"* | | $A3\" >> expected &&\n-\techo \"| |/  \" >> expected &&\n-\techo \"|/|   \" >> expected &&\n-\techo \"* | $A2\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --all > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. | A4\n+\t|\\ \\|\n+\t| | * C2\n+\t| | * C1\n+\t| * | B2\n+\t| * | B1\n+\t* | | A3\n+\t| |/\n+\t|/|\n+\t* | A2\n+\t|/\n+\t* A1\n+\tEOF\n+'\n \n # Make sure the graph_is_interesting() code still realizes\n # that undecorated merges are interesting, even with --simplify-by-decoration\n test_expect_success '--graph --simplify-by-decoration' '\n-\trm -f expected &&\n \tgit tag -d A4 &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |   \" >> expected &&\n-\techo \"|  \\\\  \" >> expected &&\n-\techo \"*-. | $A4\" >> expected &&\n-\techo \"|\\\\ \\\\| \" >> expected &&\n-\techo \"| | * $C2\" >> expected &&\n-\techo \"| | * $C1\" >> expected &&\n-\techo \"| * | $B2\" >> expected &&\n-\techo \"| * | $B1\" >> expected &&\n-\techo \"* | | $A3\" >> expected &&\n-\techo \"| |/  \" >> expected &&\n-\techo \"|/|   \" >> expected &&\n-\techo \"* | $A2\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --all --simplify-by-decoration > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all --simplify-by-decoration <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. | A4\n+\t|\\ \\|\n+\t| | * C2\n+\t| | * C1\n+\t| * | B2\n+\t| * | B1\n+\t* | | A3\n+\t| |/\n+\t|/|\n+\t* | A2\n+\t|/\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success 'setup: get rid of decorations on B' '\n \tgit tag -d B2 &&\n@@ -122,142 +111,133 @@ test_expect_success 'setup: get rid of decorations on B' '\n \n # Graph with branch B simplified away\n test_expect_success '--graph --simplify-by-decoration prune branch B' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A4\" >> expected &&\n-\techo \"|\\\\| \" >> expected &&\n-\techo \"| * $C2\" >> expected &&\n-\techo \"| * $C1\" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --simplify-by-decoration --all > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --simplify-by-decoration --all <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t| * C3\n+\t* | A5\n+\t* | A4\n+\t|\\|\n+\t| * C2\n+\t| * C1\n+\t* | A3\n+\t|/\n+\t* A2\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success '--graph --full-history -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A4\" >> expected &&\n-\techo \"|\\\\| \" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --full-history --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --full-history --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t* | A4\n+\t|\\|\n+\t* | A3\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"* | $A3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --full-history --simplify-merges --all \\\n-\t\t-- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --full-history --simplify-merges --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t* | A3\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\tgit rev-list --graph --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t* A5\n+\t* A3\n+\t| * C4\n+\t|/\n+\t* A2\n+\tEOF\n+'\n \n test_expect_success '--graph --sparse -- bar.txt' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A6\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"* $A4\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"| * $C3\" >> expected &&\n-\techo \"| * $C2\" >> expected &&\n-\techo \"| * $C1\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"* $A2\" >> expected &&\n-\techo \"* $A1\" >> expected &&\n-\tgit rev-list --graph --sparse --all -- bar.txt > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --sparse --all -- bar.txt <<-\\EOF\n+\t* A7\n+\t* A6\n+\t* A5\n+\t* A4\n+\t* A3\n+\t| * C4\n+\t| * C3\n+\t| * C2\n+\t| * C1\n+\t|/\n+\t* A2\n+\t* A1\n+\tEOF\n+'\n \n test_expect_success '--graph ^C4' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"* $A6\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"*   $A4\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $B2\" >> expected &&\n-\techo \"| * $B1\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\tgit rev-list --graph --all ^C4 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all ^C4 <<-\\EOF\n+\t* A7\n+\t* A6\n+\t* A5\n+\t*   A4\n+\t|\\\n+\t| * B2\n+\t| * B1\n+\t* A3\n+\tEOF\n+'\n \n test_expect_success '--graph ^C3' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* $A5\" >> expected &&\n-\techo \"*   $A4\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $B2\" >> expected &&\n-\techo \"| * $B1\" >> expected &&\n-\techo \"* $A3\" >> expected &&\n-\tgit rev-list --graph --all ^C3 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --all ^C3 <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* A5\n+\t*   A4\n+\t|\\\n+\t| * B2\n+\t| * B1\n+\t* A3\n+\tEOF\n+'\n \n # I don't think the ordering of the boundary commits is really\n # that important, but this test depends on it.  If the ordering ever changes\n # in the code, we'll need to update this test.\n test_expect_success '--graph --boundary ^C3' '\n-\trm -f expected &&\n-\techo \"* $A7\" >> expected &&\n-\techo \"*   $A6\" >> expected &&\n-\techo \"|\\\\  \" >> expected &&\n-\techo \"| * $C4\" >> expected &&\n-\techo \"* | $A5\" >> expected &&\n-\techo \"| |     \" >> expected &&\n-\techo \"|  \\\\    \" >> expected &&\n-\techo \"*-. \\\\   $A4\" >> expected &&\n-\techo \"|\\\\ \\\\ \\\\  \" >> expected &&\n-\techo \"| * | | $B2\" >> expected &&\n-\techo \"| * | | $B1\" >> expected &&\n-\techo \"* | | | $A3\" >> expected &&\n-\techo \"o | | | $A2\" >> expected &&\n-\techo \"|/ / /  \" >> expected &&\n-\techo \"o / / $A1\" >> expected &&\n-\techo \" / /  \" >> expected &&\n-\techo \"| o $C3\" >> expected &&\n-\techo \"|/  \" >> expected &&\n-\techo \"o $C2\" >> expected &&\n-\tgit rev-list --graph --boundary --all ^C3 > actual &&\n-\ttest_cmp expected actual\n-\t'\n+\tcheck_graph --boundary --all ^C3 <<-\\EOF\n+\t* A7\n+\t*   A6\n+\t|\\\n+\t| * C4\n+\t* | A5\n+\t| |\n+\t|  \\\n+\t*-. \\   A4\n+\t|\\ \\ \\\n+\t| * | | B2\n+\t| * | | B1\n+\t* | | | A3\n+\to | | | A2\n+\t|/ / /\n+\to / / A1\n+\t / /\n+\t| o C3\n+\t|/\n+\to C2\n+\tEOF\n+'\n \n test_done\n-- \n2.30.0\n\n"}]}