{"thread":{"id":"7442","subject":"[PATCH] Add some basic tests of rev-list --pretty=format","startedAt":"2007-03-28T00:08:28Z","lastAt":"2007-03-28T20:37:08Z","messageCount":5,"participants":["Jeff King","Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38210","messageId":"20070328000828.GA13273@coredump.intra.peff.net","threadId":"7442","inReplyTo":null,"subject":"[PATCH] Add some basic tests of rev-list --pretty=format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-03-28T00:08:28Z","receivedAt":"2007-03-28T00:08:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"These could stand to be a little more complex, but it should\nat least catch obvious problems (like the recently fixed %ct\nbug).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n\nJunio: warning, there is (intentional) trailing whitespace in one of the\ntest results.\n\n t/t6006-rev-list-format.sh |  108 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 108 insertions(+), 0 deletions(-)\n create mode 100644 t/t6006-rev-list-format.sh\n\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nnew file mode 100644\nindex 0000000..cf096c3\n--- /dev/null\n+++ b/t/t6006-rev-list-format.sh\n@@ -0,0 +1,108 @@\n+#!/bin/sh\n+\n+test_description='git-rev-list --pretty=format test'\n+\n+. ./test-lib.sh\n+\n+test_tick\n+test_expect_success 'setup' '\n+touch foo && git-add foo && git-commit -m \"added foo\" &&\n+  echo changed >foo && git-commit -a -m \"changed foo\"\n+'\n+\n+# usage: test_format name format_string <expected_output\n+test_format() {\n+\tcat >expect.$1\n+\ttest_expect_success \"format $1\" \"\n+git-rev-list --pretty=format:$2 master >output.$1 &&\n+git-diff expect.$1 output.$1\n+\"\n+}\n+\n+test_format hash %H%n%h <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+131a310eb913d107dd3c09a65d1651175898735d\n+131a310\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+86c75cf\n+EOF\n+\n+test_format tree %T%n%t <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+fe722612f26da5064c32ca3843aa154bdb0b08a0\n+fe72261\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+4d5fcadc293a348e88f777dc0920f11e7d71441c\n+4d5fcad\n+EOF\n+\n+test_format parents %P%n%p <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+86c75cfd708a0e5868dc876ed5b8bb66c80b4873 \n+86c75cf \n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+86c75cf \n+86c75cf \n+EOF\n+\n+# we don't test relative here\n+test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+A U Thor\n+author@example.com\n+Thu Apr 7 15:13:13 2005 -0700\n+Thu, 7 Apr 2005 15:13:13 -0700\n+1112911993\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+A U Thor\n+author@example.com\n+Thu Apr 7 15:13:13 2005 -0700\n+Thu, 7 Apr 2005 15:13:13 -0700\n+1112911993\n+EOF\n+\n+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+C O Mitter\n+committer@example.com\n+Thu Apr 7 15:13:13 2005 -0700\n+Thu, 7 Apr 2005 15:13:13 -0700\n+1112911993\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+C O Mitter\n+committer@example.com\n+Thu Apr 7 15:13:13 2005 -0700\n+Thu, 7 Apr 2005 15:13:13 -0700\n+1112911993\n+EOF\n+\n+test_format encoding %e <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+<unknown>\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+<unknown>\n+EOF\n+\n+test_format subject %s <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+changed foo\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+added foo\n+EOF\n+\n+test_format body %b <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+<unknown>\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+<unknown>\n+EOF\n+\n+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'\n+commit 131a310eb913d107dd3c09a65d1651175898735d\n+\u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+\u001b[31mfoo\u001b[32mbar\u001b[34mbaz\u001b[mxyzzy\n+EOF\n+\n+test_done\n-- \n1.5.1.rc2.619.g9dd2d\n"},{"id":"38259","messageId":"20070328192111.GA2588@steel.home","threadId":"7442","inReplyTo":"20070328000828.GA13273@coredump.intra.peff.net","subject":"Re: [PATCH] Add some basic tests of rev-list --pretty=format","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-28T19:21:11Z","receivedAt":"2007-03-28T19:21:11Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Jeff King, Wed, Mar 28, 2007 02:08:28 +0200:\n> +test_format parents %P%n%p <<'EOF'\n> +commit 131a310eb913d107dd3c09a65d1651175898735d\n> +86c75cfd708a0e5868dc876ed5b8bb66c80b4873 \n> +86c75cf \n> +commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n> +86c75cf \n> +86c75cf \n> +EOF\n\nIsn't this a bit wrong for initial commit?\n"},{"id":"38262","messageId":"20070328201123.GB2588@steel.home","threadId":"7442","inReplyTo":"20070328000828.GA13273@coredump.intra.peff.net","subject":"[PATCH] Improve output of %p and %P format in git-rev-list --pretty=format:","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-28T20:11:23Z","receivedAt":"2007-03-28T20:11:23Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Remove the terminating space from the space-separated list of parents.\nAlso fix the test t6006: it wrongly assumed that the initial commit\nhas a parent and was not executable.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nThe test even hardcoded parents of the initial commit to the\ninitial commit itself, which does not make any sense at all.\n\n commit.c                   |    5 +++--\n t/t6006-rev-list-format.sh |    8 ++++----\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex a92958c..94b3713 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -852,13 +852,14 @@ static long format_commit_message(const struct commit *commit,\n \tfor (i = 0, p = commit->parents;\n \t\t\tp && i < sizeof(parents) - 1;\n \t\t\tp = p->next)\n-\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \"%s \",\n+\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \" %s\" + !i,\n \t\t\tsha1_to_hex(p->item->object.sha1));\n \tinterp_set_entry(table, IPARENTS, parents);\n+\t*parents = '\\0';\n \tfor (i = 0, p = commit->parents;\n \t\t\tp && i < sizeof(parents) - 1;\n \t\t\tp = p->next)\n-\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \"%s \",\n+\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \" %s\" + !i,\n \t\t\tfind_unique_abbrev(p->item->object.sha1,\n \t\t\t\tDEFAULT_ABBREV));\n \tinterp_set_entry(table, IPARENTS_ABBREV, parents);\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex cf096c3..ce9c7dc 100644\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -39,11 +39,11 @@ EOF\n \n test_format parents %P%n%p <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873 \n-86c75cf \n+86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+86c75cf\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf \n-86c75cf \n+\n+\n EOF\n \n # we don't test relative here\n-- \n1.5.1.rc2.18.g157b4\n"},{"id":"38263","messageId":"20070328202409.GA32092@coredump.intra.peff.net","threadId":"7442","inReplyTo":"20070328201123.GB2588@steel.home","subject":"Re: [PATCH] Improve output of %p and %P format in git-rev-list --pretty=format:","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-03-28T20:24:09Z","receivedAt":"2007-03-28T20:24:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 28, 2007 at 10:11:23PM +0200, Alex Riesen wrote:\n\n> Remove the terminating space from the space-separated list of parents.\n> Also fix the test t6006: it wrongly assumed that the initial commit\n> has a parent and was not executable.\n\nArgh, yes. As is probably obvious, I moved the actual output to be\n'expected' after giving it a cursory check, but I was more focused on\nthe author/committer information, since that's where I was fixing bugs.\nGood catch.\n\nThis is obviously fairly untested code.  I will follow up with a few\nmore tests for encoding/body to help make it more complete.\n\n-Peff\n"},{"id":"38264","messageId":"7vhcs5f6kr.fsf_-_@assigned-by-dhcp.cox.net","threadId":"7442","inReplyTo":"20070328192111.GA2588@steel.home","subject":"[PATCH] Fix \"--pretty=format:\" for parent related items.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-28T20:37:08Z","receivedAt":"2007-03-28T20:37:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"There are two breakages in the %P/%p interpolation.  It appended\nan excess SP at the end of the list, and it gave uninitialized\ncontents of a buffer on the stack for root commits.\n\nThis fixes it, while updating the t6006 test which expected the\nwrong output.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n commit.c                   |   12 ++++++++----\n t/t6006-rev-list-format.sh |    8 ++++----\n 2 files changed, 12 insertions(+), 8 deletions(-)\n mode change 100644 => 100755 t/t6006-rev-list-format.sh\n\ndiff --git a/commit.c b/commit.c\nindex a92958c..33b63c4 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -849,19 +849,23 @@ static long format_commit_message(const struct commit *commit,\n \tinterp_set_entry(table, ITREE_ABBREV,\n \t\t\tfind_unique_abbrev(commit->tree->object.sha1,\n \t\t\t\tDEFAULT_ABBREV));\n+\n+\tparents[1] = 0;\n \tfor (i = 0, p = commit->parents;\n \t\t\tp && i < sizeof(parents) - 1;\n \t\t\tp = p->next)\n-\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \"%s \",\n+\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \" %s\",\n \t\t\tsha1_to_hex(p->item->object.sha1));\n-\tinterp_set_entry(table, IPARENTS, parents);\n+\tinterp_set_entry(table, IPARENTS, parents + 1);\n+\n+\tparents[1] = 0;\n \tfor (i = 0, p = commit->parents;\n \t\t\tp && i < sizeof(parents) - 1;\n \t\t\tp = p->next)\n-\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \"%s \",\n+\t\ti += snprintf(parents + i, sizeof(parents) - i - 1, \" %s\",\n \t\t\tfind_unique_abbrev(p->item->object.sha1,\n \t\t\t\tDEFAULT_ABBREV));\n-\tinterp_set_entry(table, IPARENTS_ABBREV, parents);\n+\tinterp_set_entry(table, IPARENTS_ABBREV, parents + 1);\n \n \tfor (i = 0, state = HEADER; msg[i] && state < BODY; i++) {\n \t\tint eol;\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nold mode 100644\nnew mode 100755\nindex cf096c3..ce9c7dc\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -39,11 +39,11 @@ EOF\n \n test_format parents %P%n%p <<'EOF'\n commit 131a310eb913d107dd3c09a65d1651175898735d\n-86c75cfd708a0e5868dc876ed5b8bb66c80b4873 \n-86c75cf \n+86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n+86c75cf\n commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873\n-86c75cf \n-86c75cf \n+\n+\n EOF\n \n # we don't test relative here\n-- \n1.5.1.rc2.632.g054ea8\n"}]}