{"thread":{"id":"44342","subject":"[PATCH v3] rev-list: use hdr_termination instead of a always using a newline","startedAt":"2016-10-20T20:41:06Z","lastAt":"2016-10-20T20:41:06Z","messageCount":1,"participants":["Jacob Keller"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"304516","messageId":"e7bcc372ec320e4b58884d35a74947711a5af1bf.1476996007.git-series.jacob.keller@gmail.com","threadId":"44342","inReplyTo":null,"subject":"[PATCH v3] rev-list: use hdr_termination instead of a always using a newline","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-10-20T20:41:00Z","receivedAt":"2016-10-20T20:41:06Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nWhen adding support for prefixing output of log and other commands using\n--line-prefix, commit 660e113ce118 (\"graph: add support for\n--line-prefix on all graph-aware output\", 2016-08-31) accidentally\nbroke rev-list --header output.\n\nIn order to make the output appear with a line-prefix, the flow was\nchanged to always use the graph subsystem for display. Unfortunately\nthe graph flow in rev-list did not use info->hdr_termination as it was\nassumed that graph output would never need to putput NULs.\n\nSince we now always use the graph code in order to handle the case of\nline-prefix, simply replace putchar('\\n') with\nputchar(info->hdr_termination) which will correct this issue.\n\nAdd a test for the --header case to make sure we don't break it in the\nfuture.\n\nReported-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\nChanges in v2\n* Squash Junio's suggested (better) test\n* Add Junio's signed-off-by since he wrote the new test\n\nChanges in v3\n* Fix commit description to not reference the no longer existing test\n\n builtin/rev-list.c       |  2 +-\n t/t6000-rev-list-misc.sh | 14 ++++++++++++++\n 2 files changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git c/builtin/rev-list.c c/builtin/rev-list.c\nindex 8479f6ed28aa..c43decda7011 100644\n--- c/builtin/rev-list.c\n+++ c/builtin/rev-list.c\n@@ -145,7 +145,7 @@ static void show_commit(struct commit *commit, void *data)\n \t\t\t */\n \t\t\tif (buf.len && buf.buf[buf.len - 1] == '\\n')\n \t\t\t\tgraph_show_padding(revs->graph);\n-\t\t\tputchar('\\n');\n+\t\t\tputchar(info->hdr_termination);\n \t\t} else {\n \t\t\t/*\n \t\t\t * If the message buffer is empty, just show\ndiff --git c/t/t6000-rev-list-misc.sh c/t/t6000-rev-list-misc.sh\nindex 3e752ce03280..969e4e9e5261 100755\n--- c/t/t6000-rev-list-misc.sh\n+++ c/t/t6000-rev-list-misc.sh\n@@ -100,4 +100,18 @@ test_expect_success '--bisect and --first-parent can not be combined' '\n \ttest_must_fail git rev-list --bisect --first-parent HEAD\n '\n \n+test_expect_success '--header shows a NUL after each commit' '\n+\t# We know that there is no Q in the true payload; names and\n+\t# addresses of the authors and the committers do not have\n+\t# any, and object names or header names do not, either.\n+\tgit rev-list --header --max-count=2 HEAD |\n+\tnul_to_q |\n+\tgrep \"^Q\" >actual &&\n+\tcat >expect <<-EOF &&\n+\tQ$(git rev-parse HEAD~1)\n+\tQ\n+\tEOF\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nbase-commit: 659889482ac63411daea38b2c3d127842ea04e4d\n-- \ngit-series 0.8.10\n"}]}