{"thread":{"id":"41954","subject":"[PATCH] format-patch: allow --no-patch to disable patch output","startedAt":"2016-04-07T16:46:39Z","lastAt":"2016-04-08T18:34:37Z","messageCount":5,"participants":["Jacob Keller","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"282848","messageId":"1460047599-9267-1-git-send-email-jacob.e.keller@intel.com","threadId":"41954","inReplyTo":null,"subject":"[PATCH] format-patch: allow --no-patch to disable patch output","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-04-07T16:46:39Z","receivedAt":"2016-04-07T16:46:39Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"The documentation for format-patch indicates that --no-patch wilL\nsuppress patch output. It also incorrectly mentions that -s will also\nsuppress the patch output, but this is incorrect because -s is used to\nadd the sign-off line first. Fix the documentation to remove the\nindication about -s. Fix builtin format-patch to prevent always adding\nthe patch incase --no-patch is given. An alternative approach would be\nto remove --no-patch from the documentation for git-format-patch, and\nadd an error check to indicate that --no-patch is not supported.\n\nAdd a test for --no-patch to ensure it functions as expected.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\n---\n Documentation/diff-options.txt |  2 ++\n builtin/log.c                  |  4 ++--\n t/t4014-format-patch.sh        | 26 ++++++++++++++++++++++++++\n 3 files changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 4b0318e2ac15..471ee47d0b07 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -27,7 +27,9 @@ ifdef::git-diff[]\n \tThis is the default.\n endif::git-diff[]\n \n+ifndef::git-format-patch[]\n -s::\n+endif::git-format-patch[]\n --no-patch::\n \tSuppress diff output. Useful for commands like `git show` that\n \tshow the patch by default, or to cancel the effect of `--patch`.\ndiff --git a/builtin/log.c b/builtin/log.c\nindex dff3fbbb437c..10f74837945b 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1390,8 +1390,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t rev.diffopt.output_format == DIFF_FORMAT_PATCH))\n \t\trev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY;\n \n-\t/* Always generate a patch */\n-\trev.diffopt.output_format |= DIFF_FORMAT_PATCH;\n+\tif (!(rev.diffopt.output_format & DIFF_FORMAT_NO_OUTPUT))\n+\t\trev.diffopt.output_format |= DIFF_FORMAT_PATCH;\n \n \trev.zero_commit = zero_commit;\n \ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex eed2981b96df..ef9cfca30a9e 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -618,6 +618,32 @@ test_expect_success 'format-patch -p suppresses stat' '\n \n '\n \n+cat >expect << EOF\n+From 422768ba4254e7abbeb467b6fe254472207e3d1f Mon Sep 17 00:00:00 2001\n+From: A U Thor <author@example.com>\n+Date: Thu, 7 Apr 2005 15:20:13 -0700\n+Subject: [PATCH 1/2] This is an excessively long subject line for a message\n+ due to the habit some projects have of not having a short, one-line subject\n+ at the start of the commit message, but rather sticking a whole paragraph\n+ right at the start as the only thing in the commit message. It had better not\n+ become the filename for the patch.\n+Header1: B E Cipient <rcipient@example.com>\n+To: Someone <someone@out.there>\n+Cc: C E Cipient <rcipient@example.com>\n+\n+-- \n+2.8.1.102.ga49ec4a.dirty\n+\n+EOF\n+\n+test_expect_success 'format-patch --no-patch suppresses patch' '\n+\n+\tgit format-patch --no-patch -2 &&\n+\tcat 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&\n+\ttest_cmp expect output\n+\n+'\n+\n test_expect_success 'format-patch from a subdirectory (1)' '\n \tfilename=$(\n \t\trm -rf sub &&\n-- \n2.8.1.102.ga49ec4a\n"},{"id":"282913","messageId":"CAPig+cRNCwFmGW-Zo+osjceA6nb=6t3+rJ2uEbnyYxGfSWQ-Uw@mail.gmail.com","threadId":"41954","inReplyTo":"1460047599-9267-1-git-send-email-jacob.e.keller@intel.com","subject":"Re: [PATCH] format-patch: allow --no-patch to disable patch output","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-04-07T21:30:58Z","receivedAt":"2016-04-07T21:30:58Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Apr 7, 2016 at 12:46 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n> The documentation for format-patch indicates that --no-patch wilL\n> suppress patch output. It also incorrectly mentions that -s will also\n> suppress the patch output, but this is incorrect because -s is used to\n> add the sign-off line first. Fix the documentation to remove the\n> indication about -s. Fix builtin format-patch to prevent always adding\n> the patch incase --no-patch is given. An alternative approach would be\n> to remove --no-patch from the documentation for git-format-patch, and\n> add an error check to indicate that --no-patch is not supported.\n\nSee [1] and [2].\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/290023\n[2]: b73a1bc (git-format-patch.txt: don't show -s as shorthand for\nmultiple options, 2016-03-27)\n\n> Add a test for --no-patch to ensure it functions as expected.\n>\n> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>\n"},{"id":"282971","messageId":"CA+P7+xoUi5H19zOCAiiwQZ0-j8yNZS9-2DzgoMmLSVOrC8Nbpw@mail.gmail.com","threadId":"41954","inReplyTo":"CAPig+cRNCwFmGW-Zo+osjceA6nb=6t3+rJ2uEbnyYxGfSWQ-Uw@mail.gmail.com","subject":"Re: [PATCH] format-patch: allow --no-patch to disable patch output","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-04-08T18:17:48Z","receivedAt":"2016-04-08T18:17:48Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, Apr 7, 2016 at 2:30 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Thu, Apr 7, 2016 at 12:46 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n>> The documentation for format-patch indicates that --no-patch wilL\n>> suppress patch output. It also incorrectly mentions that -s will also\n>> suppress the patch output, but this is incorrect because -s is used to\n>> add the sign-off line first. Fix the documentation to remove the\n>> indication about -s. Fix builtin format-patch to prevent always adding\n>> the patch incase --no-patch is given. An alternative approach would be\n>> to remove --no-patch from the documentation for git-format-patch, and\n>> add an error check to indicate that --no-patch is not supported.\n>\n> See [1] and [2].\n>\n> [1]: http://thread.gmane.org/gmane.comp.version-control.git/290023\n> [2]: b73a1bc (git-format-patch.txt: don't show -s as shorthand for\n> multiple options, 2016-03-27)\n>\n>> Add a test for --no-patch to ensure it functions as expected.\n>>\n>> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nSo if I want to get the summary of a patch out of a commit without the\nactual diff what would you suggest?\n\nBasically, I have a process where we have post processed code, and I\nwant to be able to generate a \"patch\" that shows the diff only of the\npost-processed code, ie:\n\ncheckout commit^ to get the parent commit, process the code, then\ncheckout the commit and process that code, and run a diff between,\nthen spit out the equivalent of \"git format-patch commit --no-patch\" +\nthe diff between the post processed code.\n\nI think maybe git show --pretty=email might work?\n\nThanks,\nJake\n"},{"id":"282973","messageId":"xmqqh9fcvtqg.fsf@gitster.mtv.corp.google.com","threadId":"41954","inReplyTo":"CA+P7+xoUi5H19zOCAiiwQZ0-j8yNZS9-2DzgoMmLSVOrC8Nbpw@mail.gmail.com","subject":"Re: [PATCH] format-patch: allow --no-patch to disable patch output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-08T18:30:15Z","receivedAt":"2016-04-08T18:30:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.keller@gmail.com> writes:\n\n> So if I want to get the summary of a patch out of a commit without the\n> actual diff what would you suggest?\n\n\"git log --stat\"?\n\nIf you have a set of (discrete) commits, \"git show --stat A B C\"?\n\n> Basically, I have a process where we have post processed code, and I\n> want to be able to generate a \"patch\" that shows the diff only of the\n> post-processed code, ie:\n\nIf you want to script and depend on the exact output, you cannot\ndepend on \"log\" or \"show\", so you would likely be doing \"cat-file\ncommit\" for log message part and \"diff-tree\" (with options like -p\nand --stat) for the patch part, I guess.\n"},{"id":"282974","messageId":"CA+P7+xrYMqcohYpWUpgAu1K=0N-3TgQi0_1sQ+z4v7nCPGcYSQ@mail.gmail.com","threadId":"41954","inReplyTo":"xmqqh9fcvtqg.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] format-patch: allow --no-patch to disable patch output","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-04-08T18:34:37Z","receivedAt":"2016-04-08T18:34:37Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Apr 8, 2016 at 11:30 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jacob Keller <jacob.keller@gmail.com> writes:\n>\n>> So if I want to get the summary of a patch out of a commit without the\n>> actual diff what would you suggest?\n>\n> \"git log --stat\"?\n>\n> If you have a set of (discrete) commits, \"git show --stat A B C\"?\n>\n>> Basically, I have a process where we have post processed code, and I\n>> want to be able to generate a \"patch\" that shows the diff only of the\n>> post-processed code, ie:\n>\n> If you want to script and depend on the exact output, you cannot\n> depend on \"log\" or \"show\", so you would likely be doing \"cat-file\n> commit\" for log message part and \"diff-tree\" (with options like -p\n> and --stat) for the patch part, I guess.\n>\n\nThe diff is being done on separate post-processed code, I can do that\npart. I just couldn't figure out how to get the same \"header\" as\nformat-patch, but without the diff, which is when I saw no-patch, and\nthen saw that it didn't work.\n\nThanks,\nJake\n"}]}