{"thread":{"id":"24890","subject":"[PATCH 0/2] Fix counting problem in `format-patch -<n>`","startedAt":"2010-08-27T20:28:14Z","lastAt":"2010-08-27T20:28:16Z","messageCount":3,"participants":["Ramkumar Ramachandra"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"149139","messageId":"1282940896-18350-1-git-send-email-artagnon@gmail.com","threadId":"24890","inReplyTo":null,"subject":"[PATCH 0/2] Fix counting problem in `format-patch -<n>`","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-08-27T20:28:14Z","receivedAt":"2010-08-27T20:28:14Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nHere's a patch avoid the 'git format-patch -3' confusion I complained\nabout earlier along with a test. 1/2 isn't strictly a prerequisite,\nbut results seem to be unpredictable without it.\n\nBased on master.\n\nRamkumar Ramachandra (2):\n  t4014-format-patch: Call test_tick before committing\n  format-patch: Don't go over merge commits\n\n Documentation/git-format-patch.txt |    2 +-\n builtin/log.c                      |    7 +------\n t/t4014-format-patch.sh            |   21 +++++++++++++++++++++\n 3 files changed, 23 insertions(+), 7 deletions(-)\n\n-- \n1.7.2.2.409.gdbb11.dirty\n"},{"id":"149140","messageId":"1282940896-18350-2-git-send-email-artagnon@gmail.com","threadId":"24890","inReplyTo":"1282940896-18350-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 1/2] t4014-format-patch: Call test_tick before committing","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-08-27T20:28:15Z","receivedAt":"2010-08-27T20:28:15Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Call test_tick before attempting to commit in the setup routine to\npreserve the order of the commits.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n t/t4014-format-patch.sh |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex f87434b..a77eeed 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -12,24 +12,29 @@ test_expect_success setup '\n \tfor i in 1 2 3 4 5 6 7 8 9 10; do echo \"$i\"; done >file &&\n \tcat file >elif &&\n \tgit add file elif &&\n+\ttest_tick &&\n \tgit commit -m Initial &&\n \tgit checkout -b side &&\n \n \tfor i in 1 2 5 6 A B C 7 8 9 10; do echo \"$i\"; done >file &&\n \ttest_chmod +x elif &&\n+\ttest_tick &&\n \tgit commit -m \"Side changes #1\" &&\n \n \tfor i in D E F; do echo \"$i\"; done >>file &&\n \tgit update-index file &&\n+\ttest_tick &&\n \tgit commit -m \"Side changes #2\" &&\n \tgit tag C2 &&\n \n \tfor i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo \"$i\"; done >file &&\n \tgit update-index file &&\n+\ttest_tick &&\n \tgit commit -m \"Side changes #3 with \\\\n backslash-n in it.\" &&\n \n \tgit checkout master &&\n \tgit diff-tree -p C2 | git apply --index &&\n+\ttest_tick &&\n \tgit commit -m \"Master accepts moral equivalent of #2\"\n \n '\n-- \n1.7.2.2.409.gdbb11.dirty\n"},{"id":"149141","messageId":"1282940896-18350-3-git-send-email-artagnon@gmail.com","threadId":"24890","inReplyTo":"1282940896-18350-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 2/2] format-patch: Don't go over merge commits","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-08-27T20:28:16Z","receivedAt":"2010-08-27T20:28:16Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"If the topmost three commits in a branch were merge commits, 'git\nformat-patch -3' used to output nothing. Since Git can't prepare\npatches out of merge commits anyway, don't go over them in the first\nplace. 'git format-patch -3' now prepares three patches from the\ntopmost three commits without counting merge commits. Also add a\ncorresponding test in t4014-format-patch and update documentation.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-format-patch.txt |    2 +-\n builtin/log.c                      |    7 +------\n t/t4014-format-patch.sh            |   16 ++++++++++++++++\n 3 files changed, 18 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 4b3f5ba..df77474 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -74,7 +74,7 @@ OPTIONS\n include::diff-options.txt[]\n \n -<n>::\n-\tLimits the number of patches to prepare.\n+\tPrepare patches from the topmost <n> commits.\n \n -o <dir>::\n --output-directory <dir>::\ndiff --git a/builtin/log.c b/builtin/log.c\nindex eaa1ee0..22d1290 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1056,8 +1056,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.commit_format = CMIT_FMT_EMAIL;\n \trev.verbose_header = 1;\n \trev.diff = 1;\n-\trev.combine_merges = 0;\n-\trev.ignore_merges = 1;\n+\trev.no_merges = 1;\n \tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n@@ -1228,10 +1227,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \n-\t\t/* ignore merges */\n-\t\tif (commit->parents && commit->parents->next)\n-\t\t\tcontinue;\n-\n \t\tif (ignore_if_in_upstream &&\n \t\t\t\thas_commit_patch_id(commit, &ids))\n \t\t\tcontinue;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex a77eeed..07bf6eb 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -56,6 +56,22 @@ test_expect_success \"format-patch --ignore-if-in-upstream\" '\n \n '\n \n+test_expect_success \"format-patch doesn't consider merge commits\" '\n+\n+\tgit checkout -b slave master &&\n+\techo \"Another line\" >>file &&\n+\ttest_tick &&\n+\tgit commit -am \"Slave change #1\" &&\n+\techo \"Yet another line\" >>file &&\n+\ttest_tick &&\n+\tgit commit -am \"Slave change #2\" &&\n+\tgit checkout -b merger master &&\n+\ttest_tick &&\n+\tgit merge --no-ff slave &&\n+\tcnt=`git format-patch -3 --stdout | grep \"^From \" | wc -l` &&\n+\ttest $cnt = 3\n+'\n+\n test_expect_success \"format-patch result applies\" '\n \n \tgit checkout -b rebuild-0 master &&\n-- \n1.7.2.2.409.gdbb11.dirty\n"}]}