{"thread":{"id":"47544","subject":"prepare-commit-msg hook no longer run for cherry-pick?","startedAt":"2018-01-05T18:48:38Z","lastAt":"2018-01-29T23:06:33Z","messageCount":23,"participants":["Dmitry Torokhov","Junio C Hamano","Phillip Wood","Eric Sunshine","Ramsay Jones","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"335937","messageId":"CAKdAkRQuj1hfKeckjuR2oP+8C1i+ZR36O-+aRYif4ufaS_zs+w@mail.gmail.com","threadId":"47544","inReplyTo":null,"subject":"prepare-commit-msg hook no longer run for cherry-pick?","fromName":"Dmitry Torokhov","fromEmail":"dmitry.torokhov@gmail.com","sentAt":"2018-01-05T18:48:29Z","receivedAt":"2018-01-05T18:48:38Z","isPatch":false,"sender":{"key":"dmitry.torokhov@gmail.com","avatar":null},"body":"Hi,\n\nI had prepare-commit-msg hook that would scrub \"Patchwork-ID: NNNN\" tags\nform commit messages and would update input mailing list patchwork to\nmark corresponding patches as \"accepted\" when I cherry pick form\nWIP/review queue into branches that I publish, but that recently stopped\nworking if I do a simple cherry-pick. If I specify that I want to edit\nthe message, then the hook is executed:\n\ndtor@dtor-ws:~/kernel/master (for-linus)$ GIT_TRACE=2 git cherry-pick ff162c1554efe951ba6c7a19a228fc76a91fe1ed    \n10:43:12.832426 git.c:344               trace: built-in: git 'cherry-pick' 'ff162c1554efe951ba6c7a19a228fc76a91fe1ed'\n[for-linus 48bc600a3659] Input: raydium_i2c_ts - include hardware version in firmware name\nAuthor: Jeffrey Lin <jeffrey.lin@rad-ic.com>\nDate: Thu Jan 4 21:35:23 2018 -0800\n1 file changed, 12 insertions(+), 2 deletions(-)\ndtor@dtor-ws:~/kernel/master (for-linus)$ gti reset --hard HEAD^            \nHEAD is now at 02a0d9216d4d Input: xen-kbdfront - do not advertise multi-touch pressure support\ndtor@dtor-ws:~/kernel/master (for-linus)$ GIT_TRACE=2 git cherry-pick -e ff162c1554efe951ba6c7a19a228fc76a91fe1ed\n10:43:24.433162 git.c:344               trace: built-in: git 'cherry-pick' '-e' 'ff162c1554efe951ba6c7a19a228fc76a91fe1ed'\n10:43:24.782355 run-command.c:627       trace: run_command: 'commit' '-n' '-e'\n10:43:24.786460 git.c:344               trace: built-in: git 'commit' '-n' '-e'\n10:43:25.082164 run-command.c:627       trace: run_command: '.git/hooks/prepare-commit-msg' '.git/COMMIT_EDITMSG' 'merge'\nhint: Waiting for your editor to close the file...\n10:43:31.491551 run-command.c:627       trace: run_command: 'vim' '/usr/local/goo gle/home/dtor/kernel/master/.git/COMMIT_EDITMSG'\n[for-linus 039c57df0ec8] Input: raydium_i2c_ts - include hardware version in firmware name\nAuthor: Jeffrey Lin <jeffrey.lin@rad-ic.com>\nDate: Thu Jan 4 21:35:23 2018 -0800\n1 file changed, 12 insertions(+), 2 deletions(-)\ndtor@dtor-ws:~/kernel/master (for-linus)$\n\nAlso note that the argument to the hook is \"merge\" whereas I think it\nused to be \"cherry-pick\" earlier.\n\nIs this behavior intentional? dpkg reports version as 2.16.0~rc0+next.\n\nThanks!\n\n-- \nDmitry\n"},{"id":"336335","messageId":"CAKdAkRTK=0Kafc-nhvJTu+9m-pp=BV3Oc-gu6ssjZZQm95pC_Q@mail.gmail.com","threadId":"47544","inReplyTo":"CAKdAkRQuj1hfKeckjuR2oP+8C1i+ZR36O-+aRYif4ufaS_zs+w@mail.gmail.com","subject":"Re: prepare-commit-msg hook no longer run for cherry-pick?","fromName":"Dmitry Torokhov","fromEmail":"dmitry.torokhov@gmail.com","sentAt":"2018-01-10T00:39:20Z","receivedAt":"2018-01-10T00:39:31Z","isPatch":false,"sender":{"key":"dmitry.torokhov@gmail.com","avatar":null},"body":"Hi Junio,\n\nOn Fri, Jan 5, 2018 at 10:48 AM, Dmitry Torokhov\n<dmitry.torokhov@gmail.com> wrote:\n> Hi,\n>\n> I had prepare-commit-msg hook that would scrub \"Patchwork-ID: NNNN\" tags\n> form commit messages and would update input mailing list patchwork to\n> mark corresponding patches as \"accepted\" when I cherry pick form\n> WIP/review queue into branches that I publish, but that recently stopped\n> working if I do a simple cherry-pick.\n\nThis seems like a regression, at least for my use case. Unfortunately\nmy mail seems to get lost in the mailing list noise... Please let me\nknow if this is indeed broken or I need to adjust my workflow.\n\nThanks!\n\n> If I specify that I want to edit\n> the message, then the hook is executed:\n>\n> dtor@dtor-ws:~/kernel/master (for-linus)$ GIT_TRACE=2 git cherry-pick ff162c1554efe951ba6c7a19a228fc76a91fe1ed\n> 10:43:12.832426 git.c:344               trace: built-in: git 'cherry-pick' 'ff162c1554efe951ba6c7a19a228fc76a91fe1ed'\n> [for-linus 48bc600a3659] Input: raydium_i2c_ts - include hardware version in firmware name\n> Author: Jeffrey Lin <jeffrey.lin@rad-ic.com>\n> Date: Thu Jan 4 21:35:23 2018 -0800\n> 1 file changed, 12 insertions(+), 2 deletions(-)\n> dtor@dtor-ws:~/kernel/master (for-linus)$ gti reset --hard HEAD^\n> HEAD is now at 02a0d9216d4d Input: xen-kbdfront - do not advertise multi-touch pressure support\n> dtor@dtor-ws:~/kernel/master (for-linus)$ GIT_TRACE=2 git cherry-pick -e ff162c1554efe951ba6c7a19a228fc76a91fe1ed\n> 10:43:24.433162 git.c:344               trace: built-in: git 'cherry-pick' '-e' 'ff162c1554efe951ba6c7a19a228fc76a91fe1ed'\n> 10:43:24.782355 run-command.c:627       trace: run_command: 'commit' '-n' '-e'\n> 10:43:24.786460 git.c:344               trace: built-in: git 'commit' '-n' '-e'\n> 10:43:25.082164 run-command.c:627       trace: run_command: '.git/hooks/prepare-commit-msg' '.git/COMMIT_EDITMSG' 'merge'\n> hint: Waiting for your editor to close the file...\n> 10:43:31.491551 run-command.c:627       trace: run_command: 'vim' '/usr/local/goo gle/home/dtor/kernel/master/.git/COMMIT_EDITMSG'\n> [for-linus 039c57df0ec8] Input: raydium_i2c_ts - include hardware version in firmware name\n> Author: Jeffrey Lin <jeffrey.lin@rad-ic.com>\n> Date: Thu Jan 4 21:35:23 2018 -0800\n> 1 file changed, 12 insertions(+), 2 deletions(-)\n> dtor@dtor-ws:~/kernel/master (for-linus)$\n>\n> Also note that the argument to the hook is \"merge\" whereas I think it\n> used to be \"cherry-pick\" earlier.\n>\n> Is this behavior intentional? dpkg reports version as 2.16.0~rc0+next.\n>\n> Thanks!\n>\n> --\n> Dmitry\n\n-- \nDmitry\n"},{"id":"336336","messageId":"xmqq1siy30zd.fsf@gitster.mtv.corp.google.com","threadId":"47544","inReplyTo":"CAKdAkRTK=0Kafc-nhvJTu+9m-pp=BV3Oc-gu6ssjZZQm95pC_Q@mail.gmail.com","subject":"Re: prepare-commit-msg hook no longer run for cherry-pick?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-10T02:24:06Z","receivedAt":"2018-01-10T02:24:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:\n\n>> I had prepare-commit-msg hook that would scrub \"Patchwork-ID: NNNN\" tags\n>> form commit messages and would update input mailing list patchwork to\n>> mark corresponding patches as \"accepted\" when I cherry pick form\n>> WIP/review queue into branches that I publish, but that recently stopped\n>> working if I do a simple cherry-pick.\n>\n> This seems like a regression, at least for my use case. Unfortunately\n> my mail seems to get lost in the mailing list noise...\n\nPossibly.  Can you bisect to see which commit broke things for you?\nThat would allow people who know what they themselves broke better\nthan I do to take a look ;-)\n\nThanks.\n"},{"id":"336408","messageId":"CAKdAkRSuNhEri+3eUbX8iVjr0JUyADSJBtgL==VjNwgKwe3Xqw@mail.gmail.com","threadId":"47544","inReplyTo":"xmqq1siy30zd.fsf@gitster.mtv.corp.google.com","subject":"Re: prepare-commit-msg hook no longer run for cherry-pick?","fromName":"Dmitry Torokhov","fromEmail":"dmitry.torokhov@gmail.com","sentAt":"2018-01-10T19:25:59Z","receivedAt":"2018-01-10T19:26:08Z","isPatch":false,"sender":{"key":"dmitry.torokhov@gmail.com","avatar":null},"body":"On Tue, Jan 9, 2018 at 6:24 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:\n>\n> >> I had prepare-commit-msg hook that would scrub \"Patchwork-ID: NNNN\" tags\n> >> form commit messages and would update input mailing list patchwork to\n> >> mark corresponding patches as \"accepted\" when I cherry pick form\n> >> WIP/review queue into branches that I publish, but that recently stopped\n> >> working if I do a simple cherry-pick.\n> >\n> > This seems like a regression, at least for my use case. Unfortunately\n> > my mail seems to get lost in the mailing list noise...\n>\n> Possibly.  Can you bisect to see which commit broke things for you?\n> That would allow people who know what they themselves broke better\n> than I do to take a look ;-)\n\nRight, so it looks like the master works well, it is next(?) branch\nthat is troublesome (apparently we pack experimental internally?).\n\nI bisected it down to:\n\ncommit 356ee4659bb551cd9464b317d691827276752c2d (refs/bisect/bad)\nAuthor: Phillip Wood <phillip.wood@dunelm.org.uk>\nDate:   Fri Nov 24 11:07:57 2017 +0000\n\n   sequencer: try to commit without forking 'git commit'\n\n   If the commit message does not need to be edited then create the\n   commit without forking 'git commit'. Taking the best time of ten runs\n   with a warm cache this reduces the time taken to cherry-pick 10\n   commits by 27% (from 282ms to 204ms), and the time taken by 'git\n   rebase --continue' to pick 10 commits by 45% (from 386ms to 212ms) on\n   my computer running linux. Some of greater saving for rebase is\n   because it no longer wastes time creating the commit summary just to\n   throw it away.\n\n   The code to create the commit is based on builtin/commit.c. It is\n   simplified as it doesn't have to deal with merges and modified so that\n   it does not die but returns an error to make sure the sequencer exits\n   cleanly, as it would when forking 'git commit'\n\n   Even when not forking 'git commit' the commit message is written to a\n   file and CHERRY_PICK_HEAD is created unnecessarily. This could be\n   eliminated in future. I hacked up a version that does not write these\n   files and just passed an strbuf (with the wrong message for fixup and\n   squash commands) to do_commit() but I couldn't measure any significant\n   time difference when running cherry-pick or rebase. I think\n   eliminating the writes properly for rebase would require a bit of\n   effort as the code would need to be restructured.\n\n   Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n   Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nWith this commit the hook is not being run unless I specify '-e' flag\nto cherry-pick.\n\nThanks.\n\n-- \nDmitry\n"},{"id":"336426","messageId":"xmqq373d1knk.fsf@gitster.mtv.corp.google.com","threadId":"47544","inReplyTo":"CAKdAkRSuNhEri+3eUbX8iVjr0JUyADSJBtgL==VjNwgKwe3Xqw@mail.gmail.com","subject":"Re: prepare-commit-msg hook no longer run for cherry-pick?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-10T21:14:23Z","receivedAt":"2018-01-10T21:14:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:\n\n> Right, so it looks like the master works well, it is next(?) branch\n> that is troublesome (apparently we pack experimental internally?).\n>\n> I bisected it down to:\n>\n> commit 356ee4659bb551cd9464b317d691827276752c2d (refs/bisect/bad)\n> Author: Phillip Wood <phillip.wood@dunelm.org.uk>\n> Date:   Fri Nov 24 11:07:57 2017 +0000\n>\n>    sequencer: try to commit without forking 'git commit'\n> ...\n>\n> With this commit the hook is not being run unless I specify '-e' flag\n> to cherry-pick.\n\nThanks.\n\n"},{"id":"336890","messageId":"20180119141940.5421-1-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"CAKdAkRSuNhEri+3eUbX8iVjr0JUyADSJBtgL==VjNwgKwe3Xqw@mail.gmail.com","subject":"[PATCH 0/2] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-19T14:19:38Z","receivedAt":"2018-01-19T14:20:20Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nThese two patches add some tests and fix the sequencer to run the\n'prepare-commit-msg' hook when committing without forking 'git commit'\n\nPhillip Wood (2):\n  t7505: Add tests for cherry-pick and rebase -i/-p\n  sequencer: run 'prepare-commit-msg' hook\n\n builtin/commit.c                   |   2 -\n sequencer.c                        |  69 ++++++++++++++++----\n sequencer.h                        |   1 +\n t/t7505-prepare-commit-msg-hook.sh | 127 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 ++++++\n 6 files changed, 215 insertions(+), 19 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\n-- \n2.15.1\n\n"},{"id":"336891","messageId":"20180119141940.5421-2-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180119141940.5421-1-phillip.wood@talktalk.net","subject":"[PATCH 1/2] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-19T14:19:39Z","receivedAt":"2018-01-19T14:20:21Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCheck that cherry-pick and rebase call the 'prepare-commit-msg' hook\ncorrectly. The expected values for the hook arguments are taken to\nmatch the current master branch. I think there is scope for improving\nthe arguments passed so they make a bit more sense - for instance\ncherry-pick currently passes different arguments depending on whether\nthe commit message is being edited. Also the arguments for rebase\ncould be improved. Commit 7c4188360ac (\"rebase -i: proper\nprepare-commit-msg hook argument when squashing\", 2008-10-3) apparently\nchanged things so that when squashing rebase would pass 'squash' as\nthe argument to the hook but that has been lost.\n\nI think that it would make more sense to pass 'message' for revert and\ncherry-pick -x/-s (i.e. cases where there is a new message or the\ncurrent message in modified by the command), 'squash' when squashing\nwith a new message and 'commit HEAD/CHERRY_PICK_HEAD'\notherwise (picking and squashing without a new message).\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n t/t7505-prepare-commit-msg-hook.sh | 127 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 ++++++\n 3 files changed, 158 insertions(+), 4 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex b13f72975ecce17887c4c8275c6935d78d4b09a0..74b2eff71e886503d41b093953b9dd6ede29de3a 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -4,6 +4,38 @@ test_description='prepare-commit-msg hook'\n \n . ./test-lib.sh\n \n+test_expect_success 'set up commits for rebasing' '\n+\ttest_commit root &&\n+\ttest_commit a a a &&\n+\ttest_commit b b b &&\n+\tgit checkout -b rebase-me root &&\n+\ttest_commit rebase-a a aa &&\n+\ttest_commit rebase-b b bb &&\n+\tfor i in $(seq 1 13)\n+\tdo\n+\t\ttest_commit rebase-$i c $i\n+\tdone &&\n+\tgit checkout master &&\n+\n+\tcat >rebase-todo <<-EOF\n+\tpick $(git rev-parse rebase-a)\n+\tpick $(git rev-parse rebase-b)\n+\tfixup $(git rev-parse rebase-1)\n+\tfixup $(git rev-parse rebase-2)\n+\tpick $(git rev-parse rebase-3)\n+\tfixup $(git rev-parse rebase-4)\n+\tsquash $(git rev-parse rebase-5)\n+\treword $(git rev-parse rebase-6)\n+\tsquash $(git rev-parse rebase-7)\n+\tfixup $(git rev-parse rebase-8)\n+\tfixup $(git rev-parse rebase-9)\n+\tedit $(git rev-parse rebase-10)\n+\tsquash $(git rev-parse rebase-11)\n+\tsquash $(git rev-parse rebase-12)\n+\tedit $(git rev-parse rebase-13)\n+\tEOF\n+'\n+\n test_expect_success 'with no hook' '\n \n \techo \"foo\" > file &&\n@@ -31,17 +63,40 @@ mkdir -p \"$HOOKDIR\"\n echo \"#!$SHELL_PATH\" > \"$HOOK\"\n cat >> \"$HOOK\" <<'EOF'\n \n+GIT_DIR=$(git rev-parse --git-dir)\n+if test -d \"$GIT_DIR/rebase-merge\"\n+then\n+  rebasing=1\n+else\n+  rebasing=0\n+fi\n+\n+get_last_cmd () {\n+  tail -n1 \"$GIT_DIR/rebase-merge/done\" | {\n+    read cmd id _\n+    git log --pretty=\"[$cmd %s]\" -n1 $id\n+  }\n+}\n+\n if test \"$2\" = commit; then\n-  source=$(git rev-parse \"$3\")\n+  if test $rebasing = 1\n+  then\n+    source=\"$3\"\n+  else\n+    source=$(git rev-parse \"$3\")\n+  fi\n else\n   source=${2-default}\n fi\n-if test \"$GIT_EDITOR\" = :; then\n-  sed -e \"1s/.*/$source (no editor)/\" \"$1\" > msg.tmp\n+test \"$GIT_EDITOR\" = : && source=\"$source (no editor)\"\n+\n+if test $rebasing = 1\n+then\n+  echo \"$source $(get_last_cmd)\" >\"$1\"\n else\n   sed -e \"1s/.*/$source/\" \"$1\" > msg.tmp\n+  mv msg.tmp \"$1\"\n fi\n-mv msg.tmp \"$1\"\n exit 0\n EOF\n chmod +x \"$HOOK\"\n@@ -156,6 +211,63 @@ test_expect_success 'with hook and editor (merge)' '\n \ttest \"$(git log -1 --pretty=format:%s)\" = \"merge\"\n '\n \n+test_rebase () {\n+\texpect=$1 &&\n+\tmode=$2 &&\n+\ttest_expect_$expect C_LOCALE_OUTPUT \"with hook (rebase $mode)\" '\n+\t\ttest_when_finished \"\\\n+\t\t\tgit rebase --abort\n+\t\t\tgit checkout -f master\n+\t\t\tgit branch -D tmp\" &&\n+\t\tgit checkout -b tmp rebase-me &&\n+\t\tGIT_SEQUENCE_EDITOR=\"cp rebase-todo\" &&\n+\t\tGIT_EDITOR=\"\\\"$FAKE_EDITOR\\\"\" &&\n+\t\t(\n+\t\t\texport GIT_SEQUENCE_EDITOR GIT_EDITOR &&\n+\t\t\ttest_must_fail git rebase $mode b &&\n+\t\t\techo x>a &&\n+\t\t\tgit add a &&\n+\t\t\ttest_must_fail git rebase --continue &&\n+\t\t\techo x>b &&\n+\t\t\tgit add b &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y>a &&\n+\t\t\tgit add a &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y>b &&\n+\t\t\tgit add b &&\n+\t\t\tgit rebase --continue\n+\t\t) &&\n+\t\tif test $mode = -p # reword amended after pick\n+\t\tthen\n+\t\t\tn=18\n+\t\telse\n+\t\t\tn=17\n+\t\tfi &&\n+\t\tgit log --pretty=%s -g -n$n HEAD@{1} >actual &&\n+\t\ttest_cmp \"$TEST_DIRECTORY/t7505/expected-rebase$mode\" actual\n+\t'\n+}\n+\n+test_rebase failure -i\n+test_rebase failure -p\n+\n+test_expect_failure 'with hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = \"message (no editor)\"\n+'\n+\n+test_expect_success 'with hook and editor (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick -e rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = merge\n+'\n+\n cat > \"$HOOK\" <<'EOF'\n #!/bin/sh\n exit 1\n@@ -197,4 +309,11 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n+test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\ttest_must_fail git cherry-pick rebase-1 2>actual &&\n+\ttest $(grep -c prepare-commit-msg actual) = 1\n+'\n+\n test_done\ndiff --git a/t/t7505/expected-rebase-i b/t/t7505/expected-rebase-i\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..c514bdbb9422c0f699a3e1c1514b41e0796214a5\n--- /dev/null\n+++ b/t/t7505/expected-rebase-i\n@@ -0,0 +1,17 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+message [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\ndiff --git a/t/t7505/expected-rebase-p b/t/t7505/expected-rebase-p\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..93bada596e25f7148fdf0b955211cedfc0fbdba3\n--- /dev/null\n+++ b/t/t7505/expected-rebase-p\n@@ -0,0 +1,18 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+HEAD [reword rebase-6]\n+message (no editor) [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\n-- \n2.15.1\n\n"},{"id":"336892","messageId":"20180119141940.5421-3-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180119141940.5421-1-phillip.wood@talktalk.net","subject":"[PATCH 2/2] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-19T14:19:40Z","receivedAt":"2018-01-19T14:20:24Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCommit 356ee4659b (\"sequencer: try to commit without forking 'git\ncommit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\ncreating the commit. Fix this by writing the commit message to a\ndifferent file and running the hook. Using a different file means that\nif the commit is cancelled the original message file is\nunchanged. Also move the checks for an empty commit so the order\nmatches 'git commit'.\n\nReported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n builtin/commit.c                   |  2 --\n sequencer.c                        | 69 +++++++++++++++++++++++++++++++-------\n sequencer.h                        |  1 +\n t/t7505-prepare-commit-msg-hook.sh |  8 ++---\n 4 files changed, 61 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 4a64428ca8ed8c3066aec7cfd8ad7b71217af7dd..5dd766af2842dddb80d30cd73b8be8ccb4956eac 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -66,8 +66,6 @@ N_(\"If you wish to skip this commit, use:\\n\"\n \"Then \\\"git cherry-pick --continue\\\" will resume cherry-picking\\n\"\n \"the remaining commits.\\n\");\n \n-static GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n-\n static const char *use_message_buffer;\n static struct lock_file index_lock; /* real index */\n static struct lock_file false_lock; /* used only for partial commits */\ndiff --git a/sequencer.c b/sequencer.c\nindex 63a8ec9a61e7a7bf603ffa494621af79b60e0b76..79579ba118e2743c3463a8662368cb4008f02165 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -29,6 +29,8 @@\n const char sign_off_header[] = \"Signed-off-by: \";\n static const char cherry_picked_prefix[] = \"(cherry picked from commit \";\n \n+GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n+\n GIT_PATH_FUNC(git_path_seq_dir, \"sequencer\")\n \n static GIT_PATH_FUNC(git_path_todo_file, \"sequencer/todo\")\n@@ -891,6 +893,31 @@ void commit_post_rewrite(const struct commit *old_head,\n \trun_rewrite_hook(&old_head->object.oid, new_head);\n }\n \n+int run_prepare_commit_msg_hook(struct strbuf *msg, const char *commit)\n+{\n+\tstruct argv_array hook_env = ARGV_ARRAY_INIT;\n+\tint ret;\n+\tconst char *name;\n+\n+\tname = git_path_commit_editmsg();\n+\tif (write_message(msg->buf, msg->len, name, 0))\n+\t\treturn -1;\n+\n+\targv_array_pushf(&hook_env, \"GIT_INDEX_FILE=%s\", get_index_file());\n+\targv_array_push(&hook_env, \"GIT_EDITOR=:\");\n+\tif (commit)\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"commit\", commit, NULL);\n+\telse\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"message\", NULL);\n+\tif (ret)\n+\t\tret = error(_(\"'prepare-commit-msg' hook failed\"));\n+\targv_array_clear(&hook_env);\n+\n+\treturn ret;\n+}\n+\n static const char implicit_ident_advice_noconfig[] =\n N_(\"Your name and email address were configured automatically based\\n\"\n \"on your username and hostname. Please check that they are accurate.\\n\"\n@@ -1051,8 +1078,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \tstruct commit_list *parents = NULL;\n \tstruct commit_extra_header *extra = NULL;\n \tstruct strbuf err = STRBUF_INIT;\n-\tstruct strbuf amend_msg = STRBUF_INIT;\n+\tstruct strbuf commit_msg = STRBUF_INIT;\n \tchar *amend_author = NULL;\n+\tconst char *hook_commit = NULL;\n \tenum commit_msg_cleanup_mode cleanup;\n \tint res = 0;\n \n@@ -1069,8 +1097,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\t\tconst char *orig_message = NULL;\n \n \t\t\tfind_commit_subject(message, &orig_message);\n-\t\t\tmsg = &amend_msg;\n+\t\t\tmsg = &commit_msg;\n \t\t\tstrbuf_addstr(msg, orig_message);\n+\t\t\thook_commit = \"HEAD\";\n \t\t}\n \t\tauthor = amend_author = get_author(message);\n \t\tunuse_commit_buffer(current_head, message);\n@@ -1084,16 +1113,6 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tcommit_list_insert(current_head, &parents);\n \t}\n \n-\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n-\t\t\t\t\t  opts->default_msg_cleanup;\n-\n-\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n-\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n-\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n-\t\tres = 1; /* run 'git commit' to display error message */\n-\t\tgoto out;\n-\t}\n-\n \tif (write_cache_as_tree(tree.hash, 0, NULL)) {\n \t\tres = error(_(\"git write-tree failed to write a tree\"));\n \t\tgoto out;\n@@ -1106,6 +1125,30 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tgoto out;\n \t}\n \n+\tif (find_hook(\"prepare-commit-msg\")) {\n+\t\tres = run_prepare_commit_msg_hook(msg, hook_commit);\n+\t\tif (res)\n+\t\t\tgoto out;\n+\t\tif (strbuf_read_file(&commit_msg, git_path_commit_editmsg(),\n+\t\t\t\t     2048) < 0) {\n+\t\t\tres = error_errno(_(\"unable to read commit message \"\n+\t\t\t\t\t      \"from '%s'\"),\n+\t\t\t\t\t    git_path_commit_editmsg());\n+\t\t\tgoto out;\n+\t\t}\n+\t\tmsg = &commit_msg;\n+\t}\n+\n+\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n+\t\t\t\t\t  opts->default_msg_cleanup;\n+\n+\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n+\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n+\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n+\t\tres = 1; /* run 'git commit' to display error message */\n+\t\tgoto out;\n+\t}\n+\n \tif (commit_tree_extended(msg->buf, msg->len, tree.hash, parents,\n \t\t\t\t oid->hash, author, opts->gpg_sign, extra)) {\n \t\tres = error(_(\"failed to write commit object\"));\n@@ -1124,7 +1167,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n out:\n \tfree_commit_extra_headers(extra);\n \tstrbuf_release(&err);\n-\tstrbuf_release(&amend_msg);\n+\tstrbuf_release(&commit_msg);\n \tfree(amend_author);\n \n \treturn res;\ndiff --git a/sequencer.h b/sequencer.h\nindex 24401b07d57b7ca875dea939f465f3e6cf1162a5..e45b178dfc41d723bf186f20674c4515d7c7fa00 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -1,6 +1,7 @@\n #ifndef SEQUENCER_H\n #define SEQUENCER_H\n \n+const char *git_path_commit_editmsg(void);\n const char *git_path_seq_dir(void);\n \n #define APPEND_SIGNOFF_DEDUP (1u << 0)\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex 74b2eff71e886503d41b093953b9dd6ede29de3a..5df914a67cd74ce7101f792b4b9edcb913c665a7 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -251,10 +251,10 @@ test_rebase () {\n \t'\n }\n \n-test_rebase failure -i\n-test_rebase failure -p\n+test_rebase success -i\n+test_rebase success -p\n \n-test_expect_failure 'with hook (cherry-pick)' '\n+test_expect_success 'with hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \tgit cherry-pick rebase-1 &&\n@@ -309,7 +309,7 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n-test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+test_expect_success C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \ttest_must_fail git cherry-pick rebase-1 2>actual &&\n-- \n2.15.1\n\n"},{"id":"336964","messageId":"CAPig+cS5BrZboaoKjCzi0TQJkR2VBnPUNJG4+WN5z8946Z4H0A@mail.gmail.com","threadId":"47544","inReplyTo":"20180119141940.5421-2-phillip.wood@talktalk.net","subject":"Re: [PATCH 1/2] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-01-20T00:48:32Z","receivedAt":"2018-01-20T00:48:38Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Jan 19, 2018 at 9:19 AM, Phillip Wood <phillip.wood@talktalk.net> wrote:\n> Check that cherry-pick and rebase call the 'prepare-commit-msg' hook\n> correctly. [...]\n>\n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> ---\n> diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\n> @@ -4,6 +4,38 @@ test_description='prepare-commit-msg hook'\n> +test_expect_success 'set up commits for rebasing' '\n> +       test_commit root &&\n> +       test_commit a a a &&\n> +       test_commit b b b &&\n> +       git checkout -b rebase-me root &&\n> +       test_commit rebase-a a aa &&\n> +       test_commit rebase-b b bb &&\n> +       for i in $(seq 1 13)\n\nFor portability, use $(test_seq ...) rather than $(seq ...).\n\n> +       do\n> +               test_commit rebase-$i c $i\n> +       done &&\n> +       git checkout master &&\n> +\n> +       cat >rebase-todo <<-EOF\n> +       pick $(git rev-parse rebase-a)\n> +       pick $(git rev-parse rebase-b)\n> +       fixup $(git rev-parse rebase-1)\n> +       fixup $(git rev-parse rebase-2)\n> +       pick $(git rev-parse rebase-3)\n> +       fixup $(git rev-parse rebase-4)\n> +       squash $(git rev-parse rebase-5)\n> +       reword $(git rev-parse rebase-6)\n> +       squash $(git rev-parse rebase-7)\n> +       fixup $(git rev-parse rebase-8)\n> +       fixup $(git rev-parse rebase-9)\n> +       edit $(git rev-parse rebase-10)\n> +       squash $(git rev-parse rebase-11)\n> +       squash $(git rev-parse rebase-12)\n> +       edit $(git rev-parse rebase-13)\n> +       EOF\n> +'\n"},{"id":"337151","messageId":"20180123102420.19911-2-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180123102420.19911-1-phillip.wood@talktalk.net","subject":"[PATCH v2 1/2] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-23T10:24:19Z","receivedAt":"2018-01-23T10:25:03Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCheck that cherry-pick and rebase call the 'prepare-commit-msg' hook\ncorrectly. The expected values for the hook arguments are taken to\nmatch the current master branch. I think there is scope for improving\nthe arguments passed so they make a bit more sense - for instance\ncherry-pick currently passes different arguments depending on whether\nthe commit message is being edited. Also the arguments for rebase\ncould be improved. Commit 7c4188360ac (\"rebase -i: proper\nprepare-commit-msg hook argument when squashing\", 2008-10-3) apparently\nchanged things so that when squashing rebase would pass 'squash' as\nthe argument to the hook but that has been lost.\n\nI think that it would make more sense to pass 'message' for revert and\ncherry-pick -x/-s (i.e. cases where there is a new message or the\ncurrent message in modified by the command), 'squash' when squashing\nwith a new message and 'commit HEAD/CHERRY_PICK_HEAD'\notherwise (picking and squashing without a new message).\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\nReviewed-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n\nNotes:\n    Changes since v1\n      - use test_seq for portability (Thanks to Eric Sunshine)\n\n t/t7505-prepare-commit-msg-hook.sh | 127 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 ++++++\n 3 files changed, 158 insertions(+), 4 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex b13f72975ecce17887c4c8275c6935d78d4b09a0..a3dd3545030c2a29a1ca4502f26b412f92f0375a 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -4,6 +4,38 @@ test_description='prepare-commit-msg hook'\n \n . ./test-lib.sh\n \n+test_expect_success 'set up commits for rebasing' '\n+\ttest_commit root &&\n+\ttest_commit a a a &&\n+\ttest_commit b b b &&\n+\tgit checkout -b rebase-me root &&\n+\ttest_commit rebase-a a aa &&\n+\ttest_commit rebase-b b bb &&\n+\tfor i in $(test_seq 1 13)\n+\tdo\n+\t\ttest_commit rebase-$i c $i\n+\tdone &&\n+\tgit checkout master &&\n+\n+\tcat >rebase-todo <<-EOF\n+\tpick $(git rev-parse rebase-a)\n+\tpick $(git rev-parse rebase-b)\n+\tfixup $(git rev-parse rebase-1)\n+\tfixup $(git rev-parse rebase-2)\n+\tpick $(git rev-parse rebase-3)\n+\tfixup $(git rev-parse rebase-4)\n+\tsquash $(git rev-parse rebase-5)\n+\treword $(git rev-parse rebase-6)\n+\tsquash $(git rev-parse rebase-7)\n+\tfixup $(git rev-parse rebase-8)\n+\tfixup $(git rev-parse rebase-9)\n+\tedit $(git rev-parse rebase-10)\n+\tsquash $(git rev-parse rebase-11)\n+\tsquash $(git rev-parse rebase-12)\n+\tedit $(git rev-parse rebase-13)\n+\tEOF\n+'\n+\n test_expect_success 'with no hook' '\n \n \techo \"foo\" > file &&\n@@ -31,17 +63,40 @@ mkdir -p \"$HOOKDIR\"\n echo \"#!$SHELL_PATH\" > \"$HOOK\"\n cat >> \"$HOOK\" <<'EOF'\n \n+GIT_DIR=$(git rev-parse --git-dir)\n+if test -d \"$GIT_DIR/rebase-merge\"\n+then\n+  rebasing=1\n+else\n+  rebasing=0\n+fi\n+\n+get_last_cmd () {\n+  tail -n1 \"$GIT_DIR/rebase-merge/done\" | {\n+    read cmd id _\n+    git log --pretty=\"[$cmd %s]\" -n1 $id\n+  }\n+}\n+\n if test \"$2\" = commit; then\n-  source=$(git rev-parse \"$3\")\n+  if test $rebasing = 1\n+  then\n+    source=\"$3\"\n+  else\n+    source=$(git rev-parse \"$3\")\n+  fi\n else\n   source=${2-default}\n fi\n-if test \"$GIT_EDITOR\" = :; then\n-  sed -e \"1s/.*/$source (no editor)/\" \"$1\" > msg.tmp\n+test \"$GIT_EDITOR\" = : && source=\"$source (no editor)\"\n+\n+if test $rebasing = 1\n+then\n+  echo \"$source $(get_last_cmd)\" >\"$1\"\n else\n   sed -e \"1s/.*/$source/\" \"$1\" > msg.tmp\n+  mv msg.tmp \"$1\"\n fi\n-mv msg.tmp \"$1\"\n exit 0\n EOF\n chmod +x \"$HOOK\"\n@@ -156,6 +211,63 @@ test_expect_success 'with hook and editor (merge)' '\n \ttest \"$(git log -1 --pretty=format:%s)\" = \"merge\"\n '\n \n+test_rebase () {\n+\texpect=$1 &&\n+\tmode=$2 &&\n+\ttest_expect_$expect C_LOCALE_OUTPUT \"with hook (rebase $mode)\" '\n+\t\ttest_when_finished \"\\\n+\t\t\tgit rebase --abort\n+\t\t\tgit checkout -f master\n+\t\t\tgit branch -D tmp\" &&\n+\t\tgit checkout -b tmp rebase-me &&\n+\t\tGIT_SEQUENCE_EDITOR=\"cp rebase-todo\" &&\n+\t\tGIT_EDITOR=\"\\\"$FAKE_EDITOR\\\"\" &&\n+\t\t(\n+\t\t\texport GIT_SEQUENCE_EDITOR GIT_EDITOR &&\n+\t\t\ttest_must_fail git rebase $mode b &&\n+\t\t\techo x>a &&\n+\t\t\tgit add a &&\n+\t\t\ttest_must_fail git rebase --continue &&\n+\t\t\techo x>b &&\n+\t\t\tgit add b &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y>a &&\n+\t\t\tgit add a &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y>b &&\n+\t\t\tgit add b &&\n+\t\t\tgit rebase --continue\n+\t\t) &&\n+\t\tif test $mode = -p # reword amended after pick\n+\t\tthen\n+\t\t\tn=18\n+\t\telse\n+\t\t\tn=17\n+\t\tfi &&\n+\t\tgit log --pretty=%s -g -n$n HEAD@{1} >actual &&\n+\t\ttest_cmp \"$TEST_DIRECTORY/t7505/expected-rebase$mode\" actual\n+\t'\n+}\n+\n+test_rebase failure -i\n+test_rebase failure -p\n+\n+test_expect_failure 'with hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = \"message (no editor)\"\n+'\n+\n+test_expect_success 'with hook and editor (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick -e rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = merge\n+'\n+\n cat > \"$HOOK\" <<'EOF'\n #!/bin/sh\n exit 1\n@@ -197,4 +309,11 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n+test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\ttest_must_fail git cherry-pick rebase-1 2>actual &&\n+\ttest $(grep -c prepare-commit-msg actual) = 1\n+'\n+\n test_done\ndiff --git a/t/t7505/expected-rebase-i b/t/t7505/expected-rebase-i\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..c514bdbb9422c0f699a3e1c1514b41e0796214a5\n--- /dev/null\n+++ b/t/t7505/expected-rebase-i\n@@ -0,0 +1,17 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+message [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\ndiff --git a/t/t7505/expected-rebase-p b/t/t7505/expected-rebase-p\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..93bada596e25f7148fdf0b955211cedfc0fbdba3\n--- /dev/null\n+++ b/t/t7505/expected-rebase-p\n@@ -0,0 +1,18 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+HEAD [reword rebase-6]\n+message (no editor) [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\n-- \n2.15.1\n\n"},{"id":"337152","messageId":"20180123102420.19911-1-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"CAKdAkRSuNhEri+3eUbX8iVjr0JUyADSJBtgL==VjNwgKwe3Xqw@mail.gmail.com","subject":"[PATCH v2 0/2] sequencer: run 'prepare-commit-msg' hook​","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-23T10:24:18Z","receivedAt":"2018-01-23T10:25:05Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nI've updated the patches in response to comments, there are just a\ncouple of small changes. Thanks to Ramsay and Eric for their reviews.\n\nBest Wishes\n\nPhillip\n\nOriginal cover letter:\n\nThese two patches add some tests and fix the sequencer to run the\n'prepare-commit-msg' hook when committing without forking 'git commit'\n\n\nPhillip Wood (2):\n  t7505: Add tests for cherry-pick and rebase -i/-p\n  sequencer: run 'prepare-commit-msg' hook\n\n builtin/commit.c                   |   2 -\n sequencer.c                        |  69 ++++++++++++++++----\n sequencer.h                        |   1 +\n t/t7505-prepare-commit-msg-hook.sh | 127 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 ++++++\n 6 files changed, 215 insertions(+), 19 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\n-- \n2.15.1\n\n"},{"id":"337153","messageId":"20180123102420.19911-3-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180123102420.19911-1-phillip.wood@talktalk.net","subject":"[PATCH v2 2/2] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-23T10:24:20Z","receivedAt":"2018-01-23T10:25:07Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCommit 356ee4659b (\"sequencer: try to commit without forking 'git\ncommit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\ncreating the commit. Fix this by writing the commit message to a\ndifferent file and running the hook. Using a different file means that\nif the commit is cancelled the original message file is\nunchanged. Also move the checks for an empty commit so the order\nmatches 'git commit'.\n\nReported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\nReviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nNotes:\n    Changes since v1:\n      - marked run_prepare_commit_msg_hook() as static (Thanks to Ramsey Jones)\n\n builtin/commit.c                   |  2 --\n sequencer.c                        | 69 +++++++++++++++++++++++++++++++-------\n sequencer.h                        |  1 +\n t/t7505-prepare-commit-msg-hook.sh |  8 ++---\n 4 files changed, 61 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 4a64428ca8ed8c3066aec7cfd8ad7b71217af7dd..5dd766af2842dddb80d30cd73b8be8ccb4956eac 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -66,8 +66,6 @@ N_(\"If you wish to skip this commit, use:\\n\"\n \"Then \\\"git cherry-pick --continue\\\" will resume cherry-picking\\n\"\n \"the remaining commits.\\n\");\n \n-static GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n-\n static const char *use_message_buffer;\n static struct lock_file index_lock; /* real index */\n static struct lock_file false_lock; /* used only for partial commits */\ndiff --git a/sequencer.c b/sequencer.c\nindex 63a8ec9a61e7a7bf603ffa494621af79b60e0b76..5bfdc4044233d5f809f9f1fbc55ebe3da477e3f0 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -29,6 +29,8 @@\n const char sign_off_header[] = \"Signed-off-by: \";\n static const char cherry_picked_prefix[] = \"(cherry picked from commit \";\n \n+GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n+\n GIT_PATH_FUNC(git_path_seq_dir, \"sequencer\")\n \n static GIT_PATH_FUNC(git_path_todo_file, \"sequencer/todo\")\n@@ -891,6 +893,31 @@ void commit_post_rewrite(const struct commit *old_head,\n \trun_rewrite_hook(&old_head->object.oid, new_head);\n }\n \n+static int run_prepare_commit_msg_hook(struct strbuf *msg, const char *commit)\n+{\n+\tstruct argv_array hook_env = ARGV_ARRAY_INIT;\n+\tint ret;\n+\tconst char *name;\n+\n+\tname = git_path_commit_editmsg();\n+\tif (write_message(msg->buf, msg->len, name, 0))\n+\t\treturn -1;\n+\n+\targv_array_pushf(&hook_env, \"GIT_INDEX_FILE=%s\", get_index_file());\n+\targv_array_push(&hook_env, \"GIT_EDITOR=:\");\n+\tif (commit)\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"commit\", commit, NULL);\n+\telse\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"message\", NULL);\n+\tif (ret)\n+\t\tret = error(_(\"'prepare-commit-msg' hook failed\"));\n+\targv_array_clear(&hook_env);\n+\n+\treturn ret;\n+}\n+\n static const char implicit_ident_advice_noconfig[] =\n N_(\"Your name and email address were configured automatically based\\n\"\n \"on your username and hostname. Please check that they are accurate.\\n\"\n@@ -1051,8 +1078,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \tstruct commit_list *parents = NULL;\n \tstruct commit_extra_header *extra = NULL;\n \tstruct strbuf err = STRBUF_INIT;\n-\tstruct strbuf amend_msg = STRBUF_INIT;\n+\tstruct strbuf commit_msg = STRBUF_INIT;\n \tchar *amend_author = NULL;\n+\tconst char *hook_commit = NULL;\n \tenum commit_msg_cleanup_mode cleanup;\n \tint res = 0;\n \n@@ -1069,8 +1097,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\t\tconst char *orig_message = NULL;\n \n \t\t\tfind_commit_subject(message, &orig_message);\n-\t\t\tmsg = &amend_msg;\n+\t\t\tmsg = &commit_msg;\n \t\t\tstrbuf_addstr(msg, orig_message);\n+\t\t\thook_commit = \"HEAD\";\n \t\t}\n \t\tauthor = amend_author = get_author(message);\n \t\tunuse_commit_buffer(current_head, message);\n@@ -1084,16 +1113,6 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tcommit_list_insert(current_head, &parents);\n \t}\n \n-\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n-\t\t\t\t\t  opts->default_msg_cleanup;\n-\n-\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n-\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n-\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n-\t\tres = 1; /* run 'git commit' to display error message */\n-\t\tgoto out;\n-\t}\n-\n \tif (write_cache_as_tree(tree.hash, 0, NULL)) {\n \t\tres = error(_(\"git write-tree failed to write a tree\"));\n \t\tgoto out;\n@@ -1106,6 +1125,30 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tgoto out;\n \t}\n \n+\tif (find_hook(\"prepare-commit-msg\")) {\n+\t\tres = run_prepare_commit_msg_hook(msg, hook_commit);\n+\t\tif (res)\n+\t\t\tgoto out;\n+\t\tif (strbuf_read_file(&commit_msg, git_path_commit_editmsg(),\n+\t\t\t\t     2048) < 0) {\n+\t\t\tres = error_errno(_(\"unable to read commit message \"\n+\t\t\t\t\t      \"from '%s'\"),\n+\t\t\t\t\t    git_path_commit_editmsg());\n+\t\t\tgoto out;\n+\t\t}\n+\t\tmsg = &commit_msg;\n+\t}\n+\n+\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n+\t\t\t\t\t  opts->default_msg_cleanup;\n+\n+\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n+\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n+\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n+\t\tres = 1; /* run 'git commit' to display error message */\n+\t\tgoto out;\n+\t}\n+\n \tif (commit_tree_extended(msg->buf, msg->len, tree.hash, parents,\n \t\t\t\t oid->hash, author, opts->gpg_sign, extra)) {\n \t\tres = error(_(\"failed to write commit object\"));\n@@ -1124,7 +1167,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n out:\n \tfree_commit_extra_headers(extra);\n \tstrbuf_release(&err);\n-\tstrbuf_release(&amend_msg);\n+\tstrbuf_release(&commit_msg);\n \tfree(amend_author);\n \n \treturn res;\ndiff --git a/sequencer.h b/sequencer.h\nindex 24401b07d57b7ca875dea939f465f3e6cf1162a5..e45b178dfc41d723bf186f20674c4515d7c7fa00 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -1,6 +1,7 @@\n #ifndef SEQUENCER_H\n #define SEQUENCER_H\n \n+const char *git_path_commit_editmsg(void);\n const char *git_path_seq_dir(void);\n \n #define APPEND_SIGNOFF_DEDUP (1u << 0)\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex a3dd3545030c2a29a1ca4502f26b412f92f0375a..512ebdde8acf38db5b3d11558e4f38c6804871c5 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -251,10 +251,10 @@ test_rebase () {\n \t'\n }\n \n-test_rebase failure -i\n-test_rebase failure -p\n+test_rebase success -i\n+test_rebase success -p\n \n-test_expect_failure 'with hook (cherry-pick)' '\n+test_expect_success 'with hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \tgit cherry-pick rebase-1 &&\n@@ -309,7 +309,7 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n-test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+test_expect_success C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \ttest_must_fail git cherry-pick rebase-1 2>actual &&\n-- \n2.15.1\n\n"},{"id":"337172","messageId":"xmqq4lncifjh.fsf@gitster.mtv.corp.google.com","threadId":"47544","inReplyTo":"20180123102420.19911-2-phillip.wood@talktalk.net","subject":"Re: [PATCH v2 1/2] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-23T18:41:22Z","receivedAt":"2018-01-23T18:41:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood@talktalk.net> writes:\n\n> @@ -31,17 +63,40 @@ mkdir -p \"$HOOKDIR\"\n>  echo \"#!$SHELL_PATH\" > \"$HOOK\"\n>  cat >> \"$HOOK\" <<'EOF'\n>  \n> +GIT_DIR=$(git rev-parse --git-dir)\n> +if test -d \"$GIT_DIR/rebase-merge\"\n> +then\n> +  rebasing=1\n> +else\n> +  rebasing=0\n> +fi\n> +\n> +get_last_cmd () {\n> +  tail -n1 \"$GIT_DIR/rebase-merge/done\" | {\n> +    read cmd id _\n> +    git log --pretty=\"[$cmd %s]\" -n1 $id\n> +  }\n> +}\n> +\n>  if test \"$2\" = commit; then\n> -  source=$(git rev-parse \"$3\")\n> +  if test $rebasing = 1\n> +  then\n> +    source=\"$3\"\n> +  else\n> +    source=$(git rev-parse \"$3\")\n> +  fi\n>  else\n>    source=${2-default}\n>  fi\n> -if test \"$GIT_EDITOR\" = :; then\n> -  sed -e \"1s/.*/$source (no editor)/\" \"$1\" > msg.tmp\n> +test \"$GIT_EDITOR\" = : && source=\"$source (no editor)\"\n> +\n> +if test $rebasing = 1\n> +then\n> +  echo \"$source $(get_last_cmd)\" >\"$1\"\n>  else\n>    sed -e \"1s/.*/$source/\" \"$1\" > msg.tmp\n> +  mv msg.tmp \"$1\"\n>  fi\n\nIt is somewhat irritating that indentation is screwed up in this\npart of the file.  Can we not make it even worse?\n\n"},{"id":"337173","messageId":"xmqqzi54h0y3.fsf@gitster.mtv.corp.google.com","threadId":"47544","inReplyTo":"20180123102420.19911-2-phillip.wood@talktalk.net","subject":"Re: [PATCH v2 1/2] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-23T18:41:56Z","receivedAt":"2018-01-23T18:42:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood@talktalk.net> writes:\n\n> +\t\t\texport GIT_SEQUENCE_EDITOR GIT_EDITOR &&\n> +\t\t\ttest_must_fail git rebase $mode b &&\n> +\t\t\techo x>a &&\n\n\"echo x >a\"\n"},{"id":"337254","messageId":"20180124123422.10637-1-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"CAKdAkRSuNhEri+3eUbX8iVjr0JUyADSJBtgL==VjNwgKwe3Xqw@mail.gmail.com","subject":"[PATCH v3 0/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-24T12:34:19Z","receivedAt":"2018-01-24T12:34:55Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nThe new test and the test hook scripts has been updated with some style\nfixes spotted by Junio. I've added an extra commit at the beginning to\nupdate the style of the original hook, so my later changes are\nclearer.\n\nOriginal cover letter:\n\nThese two patches add some tests and fix the sequencer to run the\n'prepare-commit-msg' hook when committing without forking 'git commit'\n\n\nPhillip Wood (3):\n  t7505: style fixes\n  t7505: Add tests for cherry-pick and rebase -i/-p\n  sequencer: run 'prepare-commit-msg' hook\n\n builtin/commit.c                   |   2 -\n sequencer.c                        |  69 +++++++++++++++----\n sequencer.h                        |   1 +\n t/t7505-prepare-commit-msg-hook.sh | 134 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 +++++\n 6 files changed, 219 insertions(+), 22 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\n-- \n2.15.1\n\n"},{"id":"337255","messageId":"20180124123422.10637-4-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180124123422.10637-1-phillip.wood@talktalk.net","subject":"[PATCH v3 3/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-24T12:34:22Z","receivedAt":"2018-01-24T12:34:58Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCommit 356ee4659b (\"sequencer: try to commit without forking 'git\ncommit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\ncreating the commit. Fix this by writing the commit message to a\ndifferent file and running the hook. Using a different file means that\nif the commit is cancelled the original message file is\nunchanged. Also move the checks for an empty commit so the order\nmatches 'git commit'.\n\nReported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\nReviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n builtin/commit.c                   |  2 --\n sequencer.c                        | 69 +++++++++++++++++++++++++++++++-------\n sequencer.h                        |  1 +\n t/t7505-prepare-commit-msg-hook.sh |  8 ++---\n 4 files changed, 61 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 4a64428ca8ed8c3066aec7cfd8ad7b71217af7dd..5dd766af2842dddb80d30cd73b8be8ccb4956eac 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -66,8 +66,6 @@ N_(\"If you wish to skip this commit, use:\\n\"\n \"Then \\\"git cherry-pick --continue\\\" will resume cherry-picking\\n\"\n \"the remaining commits.\\n\");\n \n-static GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n-\n static const char *use_message_buffer;\n static struct lock_file index_lock; /* real index */\n static struct lock_file false_lock; /* used only for partial commits */\ndiff --git a/sequencer.c b/sequencer.c\nindex 63a8ec9a61e7a7bf603ffa494621af79b60e0b76..5bfdc4044233d5f809f9f1fbc55ebe3da477e3f0 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -29,6 +29,8 @@\n const char sign_off_header[] = \"Signed-off-by: \";\n static const char cherry_picked_prefix[] = \"(cherry picked from commit \";\n \n+GIT_PATH_FUNC(git_path_commit_editmsg, \"COMMIT_EDITMSG\")\n+\n GIT_PATH_FUNC(git_path_seq_dir, \"sequencer\")\n \n static GIT_PATH_FUNC(git_path_todo_file, \"sequencer/todo\")\n@@ -891,6 +893,31 @@ void commit_post_rewrite(const struct commit *old_head,\n \trun_rewrite_hook(&old_head->object.oid, new_head);\n }\n \n+static int run_prepare_commit_msg_hook(struct strbuf *msg, const char *commit)\n+{\n+\tstruct argv_array hook_env = ARGV_ARRAY_INIT;\n+\tint ret;\n+\tconst char *name;\n+\n+\tname = git_path_commit_editmsg();\n+\tif (write_message(msg->buf, msg->len, name, 0))\n+\t\treturn -1;\n+\n+\targv_array_pushf(&hook_env, \"GIT_INDEX_FILE=%s\", get_index_file());\n+\targv_array_push(&hook_env, \"GIT_EDITOR=:\");\n+\tif (commit)\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"commit\", commit, NULL);\n+\telse\n+\t\tret = run_hook_le(hook_env.argv, \"prepare-commit-msg\", name,\n+\t\t\t\t  \"message\", NULL);\n+\tif (ret)\n+\t\tret = error(_(\"'prepare-commit-msg' hook failed\"));\n+\targv_array_clear(&hook_env);\n+\n+\treturn ret;\n+}\n+\n static const char implicit_ident_advice_noconfig[] =\n N_(\"Your name and email address were configured automatically based\\n\"\n \"on your username and hostname. Please check that they are accurate.\\n\"\n@@ -1051,8 +1078,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \tstruct commit_list *parents = NULL;\n \tstruct commit_extra_header *extra = NULL;\n \tstruct strbuf err = STRBUF_INIT;\n-\tstruct strbuf amend_msg = STRBUF_INIT;\n+\tstruct strbuf commit_msg = STRBUF_INIT;\n \tchar *amend_author = NULL;\n+\tconst char *hook_commit = NULL;\n \tenum commit_msg_cleanup_mode cleanup;\n \tint res = 0;\n \n@@ -1069,8 +1097,9 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\t\tconst char *orig_message = NULL;\n \n \t\t\tfind_commit_subject(message, &orig_message);\n-\t\t\tmsg = &amend_msg;\n+\t\t\tmsg = &commit_msg;\n \t\t\tstrbuf_addstr(msg, orig_message);\n+\t\t\thook_commit = \"HEAD\";\n \t\t}\n \t\tauthor = amend_author = get_author(message);\n \t\tunuse_commit_buffer(current_head, message);\n@@ -1084,16 +1113,6 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tcommit_list_insert(current_head, &parents);\n \t}\n \n-\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n-\t\t\t\t\t  opts->default_msg_cleanup;\n-\n-\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n-\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n-\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n-\t\tres = 1; /* run 'git commit' to display error message */\n-\t\tgoto out;\n-\t}\n-\n \tif (write_cache_as_tree(tree.hash, 0, NULL)) {\n \t\tres = error(_(\"git write-tree failed to write a tree\"));\n \t\tgoto out;\n@@ -1106,6 +1125,30 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tgoto out;\n \t}\n \n+\tif (find_hook(\"prepare-commit-msg\")) {\n+\t\tres = run_prepare_commit_msg_hook(msg, hook_commit);\n+\t\tif (res)\n+\t\t\tgoto out;\n+\t\tif (strbuf_read_file(&commit_msg, git_path_commit_editmsg(),\n+\t\t\t\t     2048) < 0) {\n+\t\t\tres = error_errno(_(\"unable to read commit message \"\n+\t\t\t\t\t      \"from '%s'\"),\n+\t\t\t\t\t    git_path_commit_editmsg());\n+\t\t\tgoto out;\n+\t\t}\n+\t\tmsg = &commit_msg;\n+\t}\n+\n+\tcleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :\n+\t\t\t\t\t  opts->default_msg_cleanup;\n+\n+\tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n+\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n+\tif (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {\n+\t\tres = 1; /* run 'git commit' to display error message */\n+\t\tgoto out;\n+\t}\n+\n \tif (commit_tree_extended(msg->buf, msg->len, tree.hash, parents,\n \t\t\t\t oid->hash, author, opts->gpg_sign, extra)) {\n \t\tres = error(_(\"failed to write commit object\"));\n@@ -1124,7 +1167,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n out:\n \tfree_commit_extra_headers(extra);\n \tstrbuf_release(&err);\n-\tstrbuf_release(&amend_msg);\n+\tstrbuf_release(&commit_msg);\n \tfree(amend_author);\n \n \treturn res;\ndiff --git a/sequencer.h b/sequencer.h\nindex 24401b07d57b7ca875dea939f465f3e6cf1162a5..e45b178dfc41d723bf186f20674c4515d7c7fa00 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -1,6 +1,7 @@\n #ifndef SEQUENCER_H\n #define SEQUENCER_H\n \n+const char *git_path_commit_editmsg(void);\n const char *git_path_seq_dir(void);\n \n #define APPEND_SIGNOFF_DEDUP (1u << 0)\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex c1f68cbcbf40b0204ae44491c60d0b12a9fd8687..1f43b3cd4cd34ec6f4c3de4cfe8a26291e4e480f 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -252,10 +252,10 @@ test_rebase () {\n \t'\n }\n \n-test_rebase failure -i\n-test_rebase failure -p\n+test_rebase success -i\n+test_rebase success -p\n \n-test_expect_failure 'with hook (cherry-pick)' '\n+test_expect_success 'with hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \tgit cherry-pick rebase-1 &&\n@@ -310,7 +310,7 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n-test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+test_expect_success C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n \ttest_when_finished \"git checkout -f master\" &&\n \tgit checkout -B other b &&\n \ttest_must_fail git cherry-pick rebase-1 2>actual &&\n-- \n2.15.1\n\n"},{"id":"337256","messageId":"20180124123422.10637-2-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180124123422.10637-1-phillip.wood@talktalk.net","subject":"[PATCH v3 1/3] t7505: style fixes","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-24T12:34:20Z","receivedAt":"2018-01-24T12:34:59Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nFix the indentation and style of the hook script in preparation for\nfurther changes.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n t/t7505-prepare-commit-msg-hook.sh | 14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex b13f72975ecce17887c4c8275c6935d78d4b09a0..cef709555eb9c3e3dec0016909a17ce7cf32650a 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -31,15 +31,17 @@ mkdir -p \"$HOOKDIR\"\n echo \"#!$SHELL_PATH\" > \"$HOOK\"\n cat >> \"$HOOK\" <<'EOF'\n \n-if test \"$2\" = commit; then\n-  source=$(git rev-parse \"$3\")\n+if test \"$2\" = commit\n+then\n+\tsource=$(git rev-parse \"$3\")\n else\n-  source=${2-default}\n+\tsource=${2-default}\n fi\n-if test \"$GIT_EDITOR\" = :; then\n-  sed -e \"1s/.*/$source (no editor)/\" \"$1\" > msg.tmp\n+if test \"$GIT_EDITOR\" = :\n+then\n+\tsed -e \"1s/.*/$source (no editor)/\" \"$1\" >msg.tmp\n else\n-  sed -e \"1s/.*/$source/\" \"$1\" > msg.tmp\n+\tsed -e \"1s/.*/$source/\" \"$1\" >msg.tmp\n fi\n mv msg.tmp \"$1\"\n exit 0\n-- \n2.15.1\n\n"},{"id":"337257","messageId":"20180124123422.10637-3-phillip.wood@talktalk.net","threadId":"47544","inReplyTo":"20180124123422.10637-1-phillip.wood@talktalk.net","subject":"[PATCH v3 2/3] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-24T12:34:21Z","receivedAt":"2018-01-24T12:35:02Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nCheck that cherry-pick and rebase call the 'prepare-commit-msg' hook\ncorrectly. The expected values for the hook arguments are taken to\nmatch the current master branch. I think there is scope for improving\nthe arguments passed so they make a bit more sense - for instance\ncherry-pick currently passes different arguments depending on whether\nthe commit message is being edited. Also the arguments for rebase\ncould be improved. Commit 7c4188360ac (\"rebase -i: proper\nprepare-commit-msg hook argument when squashing\", 2008-10-3) apparently\nchanged things so that when squashing rebase would pass 'squash' as\nthe argument to the hook but that has been lost.\n\nI think that it would make more sense to pass 'message' for revert and\ncherry-pick -x/-s (i.e. cases where there is a new message or the\ncurrent message in modified by the command), 'squash' when squashing\nwith a new message and 'commit HEAD/CHERRY_PICK_HEAD'\notherwise (picking and squashing without a new message).\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\nReviewed-by: Eric Sunshine <sunshine@sunshineco.com>\nReviewed-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t7505-prepare-commit-msg-hook.sh | 126 +++++++++++++++++++++++++++++++++++--\n t/t7505/expected-rebase-i          |  17 +++++\n t/t7505/expected-rebase-p          |  18 ++++++\n 3 files changed, 157 insertions(+), 4 deletions(-)\n create mode 100644 t/t7505/expected-rebase-i\n create mode 100644 t/t7505/expected-rebase-p\n\ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex cef709555eb9c3e3dec0016909a17ce7cf32650a..c1f68cbcbf40b0204ae44491c60d0b12a9fd8687 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -4,6 +4,38 @@ test_description='prepare-commit-msg hook'\n \n . ./test-lib.sh\n \n+test_expect_success 'set up commits for rebasing' '\n+\ttest_commit root &&\n+\ttest_commit a a a &&\n+\ttest_commit b b b &&\n+\tgit checkout -b rebase-me root &&\n+\ttest_commit rebase-a a aa &&\n+\ttest_commit rebase-b b bb &&\n+\tfor i in $(test_seq 1 13)\n+\tdo\n+\t\ttest_commit rebase-$i c $i\n+\tdone &&\n+\tgit checkout master &&\n+\n+\tcat >rebase-todo <<-EOF\n+\tpick $(git rev-parse rebase-a)\n+\tpick $(git rev-parse rebase-b)\n+\tfixup $(git rev-parse rebase-1)\n+\tfixup $(git rev-parse rebase-2)\n+\tpick $(git rev-parse rebase-3)\n+\tfixup $(git rev-parse rebase-4)\n+\tsquash $(git rev-parse rebase-5)\n+\treword $(git rev-parse rebase-6)\n+\tsquash $(git rev-parse rebase-7)\n+\tfixup $(git rev-parse rebase-8)\n+\tfixup $(git rev-parse rebase-9)\n+\tedit $(git rev-parse rebase-10)\n+\tsquash $(git rev-parse rebase-11)\n+\tsquash $(git rev-parse rebase-12)\n+\tedit $(git rev-parse rebase-13)\n+\tEOF\n+'\n+\n test_expect_success 'with no hook' '\n \n \techo \"foo\" > file &&\n@@ -31,19 +63,41 @@ mkdir -p \"$HOOKDIR\"\n echo \"#!$SHELL_PATH\" > \"$HOOK\"\n cat >> \"$HOOK\" <<'EOF'\n \n+GIT_DIR=$(git rev-parse --git-dir)\n+if test -d \"$GIT_DIR/rebase-merge\"\n+then\n+\trebasing=1\n+else\n+\trebasing=0\n+fi\n+\n+get_last_cmd () {\n+\ttail -n1 \"$GIT_DIR/rebase-merge/done\" | {\n+\t\tread cmd id _\n+\t\tgit log --pretty=\"[$cmd %s]\" -n1 $id\n+\t}\n+}\n+\n if test \"$2\" = commit\n then\n-\tsource=$(git rev-parse \"$3\")\n+\tif test $rebasing = 1\n+\tthen\n+\t\tsource=\"$3\"\n+\telse\n+\t\tsource=$(git rev-parse \"$3\")\n+\tfi\n else\n \tsource=${2-default}\n fi\n-if test \"$GIT_EDITOR\" = :\n+test \"$GIT_EDITOR\" = : && source=\"$source (no editor)\"\n+\n+if test $rebasing = 1\n then\n-\tsed -e \"1s/.*/$source (no editor)/\" \"$1\" >msg.tmp\n+\techo \"$source $(get_last_cmd)\" >\"$1\"\n else\n \tsed -e \"1s/.*/$source/\" \"$1\" >msg.tmp\n+\tmv msg.tmp \"$1\"\n fi\n-mv msg.tmp \"$1\"\n exit 0\n EOF\n chmod +x \"$HOOK\"\n@@ -158,6 +212,63 @@ test_expect_success 'with hook and editor (merge)' '\n \ttest \"$(git log -1 --pretty=format:%s)\" = \"merge\"\n '\n \n+test_rebase () {\n+\texpect=$1 &&\n+\tmode=$2 &&\n+\ttest_expect_$expect C_LOCALE_OUTPUT \"with hook (rebase $mode)\" '\n+\t\ttest_when_finished \"\\\n+\t\t\tgit rebase --abort\n+\t\t\tgit checkout -f master\n+\t\t\tgit branch -D tmp\" &&\n+\t\tgit checkout -b tmp rebase-me &&\n+\t\tGIT_SEQUENCE_EDITOR=\"cp rebase-todo\" &&\n+\t\tGIT_EDITOR=\"\\\"$FAKE_EDITOR\\\"\" &&\n+\t\t(\n+\t\t\texport GIT_SEQUENCE_EDITOR GIT_EDITOR &&\n+\t\t\ttest_must_fail git rebase $mode b &&\n+\t\t\techo x >a &&\n+\t\t\tgit add a &&\n+\t\t\ttest_must_fail git rebase --continue &&\n+\t\t\techo x >b &&\n+\t\t\tgit add b &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y >a &&\n+\t\t\tgit add a &&\n+\t\t\tgit commit &&\n+\t\t\tgit rebase --continue &&\n+\t\t\techo y >b &&\n+\t\t\tgit add b &&\n+\t\t\tgit rebase --continue\n+\t\t) &&\n+\t\tif test $mode = -p # reword amended after pick\n+\t\tthen\n+\t\t\tn=18\n+\t\telse\n+\t\t\tn=17\n+\t\tfi &&\n+\t\tgit log --pretty=%s -g -n$n HEAD@{1} >actual &&\n+\t\ttest_cmp \"$TEST_DIRECTORY/t7505/expected-rebase$mode\" actual\n+\t'\n+}\n+\n+test_rebase failure -i\n+test_rebase failure -p\n+\n+test_expect_failure 'with hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = \"message (no editor)\"\n+'\n+\n+test_expect_success 'with hook and editor (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\tgit cherry-pick -e rebase-1 &&\n+\ttest \"$(git log -1 --pretty=format:%s)\" = merge\n+'\n+\n cat > \"$HOOK\" <<'EOF'\n #!/bin/sh\n exit 1\n@@ -199,4 +310,11 @@ test_expect_success 'with failing hook (merge)' '\n \n '\n \n+test_expect_failure C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' '\n+\ttest_when_finished \"git checkout -f master\" &&\n+\tgit checkout -B other b &&\n+\ttest_must_fail git cherry-pick rebase-1 2>actual &&\n+\ttest $(grep -c prepare-commit-msg actual) = 1\n+'\n+\n test_done\ndiff --git a/t/t7505/expected-rebase-i b/t/t7505/expected-rebase-i\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..c514bdbb9422c0f699a3e1c1514b41e0796214a5\n--- /dev/null\n+++ b/t/t7505/expected-rebase-i\n@@ -0,0 +1,17 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+message [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\ndiff --git a/t/t7505/expected-rebase-p b/t/t7505/expected-rebase-p\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..93bada596e25f7148fdf0b955211cedfc0fbdba3\n--- /dev/null\n+++ b/t/t7505/expected-rebase-p\n@@ -0,0 +1,18 @@\n+message [edit rebase-13]\n+message (no editor) [edit rebase-13]\n+message [squash rebase-12]\n+message (no editor) [squash rebase-11]\n+default [edit rebase-10]\n+message (no editor) [edit rebase-10]\n+message [fixup rebase-9]\n+message (no editor) [fixup rebase-8]\n+message (no editor) [squash rebase-7]\n+HEAD [reword rebase-6]\n+message (no editor) [reword rebase-6]\n+message [squash rebase-5]\n+message (no editor) [fixup rebase-4]\n+message (no editor) [pick rebase-3]\n+message (no editor) [fixup rebase-2]\n+message (no editor) [fixup rebase-1]\n+merge [pick rebase-b]\n+message [pick rebase-a]\n-- \n2.15.1\n\n"},{"id":"337279","messageId":"CAPig+cRryaafwP4gBLe_6ebWZo12HWtEC6e2CbbP6a5gVh6W4w@mail.gmail.com","threadId":"47544","inReplyTo":"20180124123422.10637-3-phillip.wood@talktalk.net","subject":"Re: [PATCH v3 2/3] t7505: Add tests for cherry-pick and rebase -i/-p","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-01-24T18:39:39Z","receivedAt":"2018-01-24T18:39:45Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 24, 2018 at 7:34 AM, Phillip Wood <phillip.wood@talktalk.net> wrote:\n> Check that cherry-pick and rebase call the 'prepare-commit-msg' hook\n> correctly. The expected values for the hook arguments are taken to\n> match the current master branch. I think there is scope for improving\n> the arguments passed so they make a bit more sense - for instance\n> cherry-pick currently passes different arguments depending on whether\n> the commit message is being edited. Also the arguments for rebase\n> could be improved. Commit 7c4188360ac (\"rebase -i: proper\n> prepare-commit-msg hook argument when squashing\", 2008-10-3) apparently\n> changed things so that when squashing rebase would pass 'squash' as\n> the argument to the hook but that has been lost.\n>\n> I think that it would make more sense to pass 'message' for revert and\n> cherry-pick -x/-s (i.e. cases where there is a new message or the\n> current message in modified by the command), 'squash' when squashing\n> with a new message and 'commit HEAD/CHERRY_PICK_HEAD'\n> otherwise (picking and squashing without a new message).\n>\n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>\n> Reviewed-by: Junio C Hamano <gitster@pobox.com>\n\nLet's drop the Reviewed-by: from me. Although I spotted a minor\nportability issue while scanning a previous iteration, I did not read\nthe patch closely enough to draw any conclusion of its overall\ncorrectness. Normally, a Reviewed-by: is given explicitly by a\nreviewer when confident that the patch is correct and meets the stated\ngoals.\n\nI suspect that Reviewed-by: Junio ought, similarly, to be dropped.\n"},{"id":"337283","messageId":"3587bc5f-c5f7-d037-6644-25e21a5f4942@ramsayjones.plus.com","threadId":"47544","inReplyTo":"20180124123422.10637-4-phillip.wood@talktalk.net","subject":"Re: [PATCH v3 3/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2018-01-24T18:51:22Z","receivedAt":"2018-01-24T18:51:31Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 24/01/18 12:34, Phillip Wood wrote:\n> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n> \n> Commit 356ee4659b (\"sequencer: try to commit without forking 'git\n> commit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\n> creating the commit. Fix this by writing the commit message to a\n> different file and running the hook. Using a different file means that\n> if the commit is cancelled the original message file is\n> unchanged. Also move the checks for an empty commit so the order\n> matches 'git commit'.\n> \n> Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> Reviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n\nEchoing Eric's earlier email, I don't think this Reviewed-by is\nwarranted - I only requested the addition of a static keyword,\nI didn't actually review the patch.\n\nThanks.\n\nATB,\nRamsay Jones\n\n\n"},{"id":"337285","messageId":"xmqqh8rbdqwk.fsf@gitster.mtv.corp.google.com","threadId":"47544","inReplyTo":"3587bc5f-c5f7-d037-6644-25e21a5f4942@ramsayjones.plus.com","subject":"Re: [PATCH v3 3/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-24T18:59:23Z","receivedAt":"2018-01-24T18:59:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> On 24/01/18 12:34, Phillip Wood wrote:\n>> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n>> \n>> Commit 356ee4659b (\"sequencer: try to commit without forking 'git\n>> commit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\n>> creating the commit. Fix this by writing the commit message to a\n>> different file and running the hook. Using a different file means that\n>> if the commit is cancelled the original message file is\n>> unchanged. Also move the checks for an empty commit so the order\n>> matches 'git commit'.\n>> \n>> Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n>> Reviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>\n> Echoing Eric's earlier email, I don't think this Reviewed-by is\n> warranted - I only requested the addition of a static keyword,\n> I didn't actually review the patch.\n\nThanks for clarification, and I tend to agree.  You, Eric and I\ncertainly did not review what is posted here, so if I \"git am\" these\npatches as-is, we'd be lying.\n\nHaving said that, I think this round takes all the review comments\nraised against the previous round(s) into account.  So I'm tempted\nto tweak them with s/Reviewed-/Helped-/ and queue.\n\nThanks, all.\n"},{"id":"337386","messageId":"f4953ce5-0fb2-e1f8-fe07-cd541a53cc4e@talktalk.net","threadId":"47544","inReplyTo":"xmqqh8rbdqwk.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 3/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-01-25T16:33:52Z","receivedAt":"2018-01-25T16:34:03Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 24/01/18 18:59, Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n> \n>> On 24/01/18 12:34, Phillip Wood wrote:\n>>> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n>>>\n>>> Commit 356ee4659b (\"sequencer: try to commit without forking 'git\n>>> commit'\", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when\n>>> creating the commit. Fix this by writing the commit message to a\n>>> different file and running the hook. Using a different file means that\n>>> if the commit is cancelled the original message file is\n>>> unchanged. Also move the checks for an empty commit so the order\n>>> matches 'git commit'.\n>>>\n>>> Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n>>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n>>> Reviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>>\n>> Echoing Eric's earlier email, I don't think this Reviewed-by is\n>> warranted - I only requested the addition of a static keyword,\n>> I didn't actually review the patch.\n> \n> Thanks for clarification, and I tend to agree.  You, Eric and I\n> certainly did not review what is posted here, so if I \"git am\" these\n> patches as-is, we'd be lying.\n> \n> Having said that, I think this round takes all the review comments\n> raised against the previous round(s) into account.  So I'm tempted\n> to tweak them with s/Reviewed-/Helped-/ and queue.\n> \nThanks Junio, I wasn't sure whether to go with Reviewed-by or Helped-by, \nI'll know for next time\n\nBest Wishes\n\nPhillip\n"},{"id":"337763","messageId":"nycvar.QRO.7.76.6.1801300004350.35@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"47544","inReplyTo":"20180124123422.10637-4-phillip.wood@talktalk.net","subject":"Re: [PATCH v3 3/3] sequencer: run 'prepare-commit-msg' hook","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-29T23:06:15Z","receivedAt":"2018-01-29T23:06:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Phillip,\n\nOn Wed, 24 Jan 2018, Phillip Wood wrote:\n\n> diff --git a/sequencer.h b/sequencer.h\n> index 24401b07d57b7ca875dea939f465f3e6cf1162a5..e45b178dfc41d723bf186f20674c4515d7c7fa00 100644\n> --- a/sequencer.h\n> +++ b/sequencer.h\n> @@ -1,6 +1,7 @@\n>  #ifndef SEQUENCER_H\n>  #define SEQUENCER_H\n>  \n> +const char *git_path_commit_editmsg(void);\n>  const char *git_path_seq_dir(void);\n>  \n>  #define APPEND_SIGNOFF_DEDUP (1u << 0)\n\nI would rather have stuck this into `commit.h` and `commit.c`, but it does\nnot really matter all that much. The rest looks good (if a little verbose\non the test front, I think testing just the cherry-pick would have\nexercised the code path enough).\n\nAll three patches are Reviewed-by: me.\n\nCiao,\nDscho\n"}]}