{"thread":{"id":"57556","subject":"git cherry-pick with --no-verify option","startedAt":"2022-03-14T05:42:11Z","lastAt":"2022-03-15T02:29:25Z","messageCount":3,"participants":["Yubin Ruan","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"451280","messageId":"CAJYFCiPw6VPPKpiC0f1iwdYf0LCFCbfrpNSHFs1qbwtGXX6pUA@mail.gmail.com","threadId":"57556","inReplyTo":null,"subject":"git cherry-pick with --no-verify option","fromName":"Yubin Ruan","fromEmail":"ablacktshirt@gmail.com","sentAt":"2022-03-14T05:41:55Z","receivedAt":"2022-03-14T05:42:11Z","isPatch":false,"sender":{"key":"ablacktshirt@gmail.com","avatar":null},"body":"Hi,\n\nIs there any version of Git that supports the cherry-pick command with\n\"--no-verify\"?\n\nIt is supported in \"git commit\" command but not in \"git cherry-pick\"\ncommand, and I always have to move .git/hooks/pre-commit away to work\naround this in case of \"git cherry-pick\".\n\nOr is there any reason that it is not included in \"cherry-pick\" command ?\n\n(Please include me in reply since I does not subscribe to the list)\n\n--\nThanks,\nYuibin\n"},{"id":"451356","messageId":"xmqqee34m8kz.fsf@gitster.g","threadId":"57556","inReplyTo":"CAJYFCiPw6VPPKpiC0f1iwdYf0LCFCbfrpNSHFs1qbwtGXX6pUA@mail.gmail.com","subject":"Re: git cherry-pick with --no-verify option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-14T23:13:16Z","receivedAt":"2022-03-14T23:13:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yubin Ruan <ablacktshirt@gmail.com> writes:\n\n> Is there any version of Git that supports the cherry-pick command with\n> \"--no-verify\"?\n>\n> It is supported in \"git commit\" command but not in \"git cherry-pick\"\n> command, and I always have to move .git/hooks/pre-commit away to work\n> around this in case of \"git cherry-pick\".\n\nDoes \"git cherry-pick\" even trigger pre-commit hook in the first\nplace?  In my quick tests, it does not seem to.\n\n $ git init test\n $ cd test\n $ printf \"%s\\n\" '#!/bin/sh' 'echo >&2 no' 'exit 1' >.git/hooks/pre-commit\n $ chmod +x .git/hooks/pre-commit\n $ git commit --allow-empty -m initial\n no\n\nUp to this point, I set up a pre-commit that stops me\nunconditionally and made sure it is working.\n\n $ git commit --no-verify --allow-empty -m initial\n [master (root-commit) 5d967c2] initial\n $ I=$(git rev-parse HEAD)\n $ echo \"foo\" >file\n $ git add file\n $ git commit --no-verify -m 'add file'\n [master 93a33c4] add file\n  1 file changed, 1 insertion(+)\n  create mode 100644 file\n\nThen I built two commits\n\n $ git checkout --detach $I\n HEAD is now at 5d967c2 initial\n\nAnd rewound to the initial commit so that the second one can be\ncherry-picked on top of it.\n\n $ git cherry-pick master\n [detached HEAD 699c604] add file\n  Date: Mon Mar 14 15:58:38 2022 -0700\n  1 file changed, 1 insertion(+)\n  create mode 100644 file\n\nAnd that is understandable, as \"cherry-pick\" is more about replaying\nwhat was committed in the past, with bugs and crufts preserved, than\ncommitting a new-and-improved version out of an existing commit.\n\nPerhaps in a case where a conflict stops the command there is\nsomething?  Let's see.  Continuing from the above transcript:\n\n $ git cherry-pick master\n HEAD detached from 5d967c2\n You are currently cherry-picking commit 93a33c4.\n   (all conflicts fixed: run \"git cherry-pick --continue\")\n   (use \"git cherry-pick --skip\" to skip this patch)\n   (use \"git cherry-pick --abort\" to cancel the cherry-pick operation)\n\n nothing to commit, working tree clean\n The previous cherry-pick is now empty, possibly due to conflict resolution.\n If you wish to commit it anyway, use:\n\n     git commit --allow-empty\n\n Otherwise, please use 'git cherry-pick --skip'\n $ edit file\n $ git commit --allow-empty -a\n no\n\nOf course, \"git commit\" to conclude a conflicted cherry-pick,\npossibly with intervening conflict resolutin by editing working tree\nfiles, would by default trigger pre-commit hook, and it of course\ntakes --no-verify as expected.\n\n $ git commit --allow-empty -a --no-verify --no-edit\n [detached HEAD 5858d22] add file\n  Date: Mon Mar 14 15:58:38 2022 -0700\n\nAhh, I think the user is fooled by a bad advice in the message.\n(all conflicts fixed: run \"git cherry-pick --continue\") is wrong and\nmisleading advice added by those who did not think things through.\n\nAfter fixing all conflicts, run \"git commit\" to record it and then\nyou run \"git cherry-pick --continue\" if there are more steps to\ncherry-pick (i.e. \"git cherry-pick A..B\").  \"git commit\" takes not\njust \"--no-verify\" but other options like \"--reset-author\" to let\nyou take over authorship if the conflict resolution (actually,\nadjusting the original commit to the different context it is being\ncherry-picked to) is so involved that a change of authorship is\nwarranted.  \"cherry-pick --continue\" does not have all the necessary\nflexibility and conceptually it is a separte operation (i.e. \"please\ncontinue the stopped sequence\" is what it means) from concluding the\ncurrent step in the sequence.\n\n\n"},{"id":"451374","messageId":"CAJYFCiOMV6P=jDOJ-yM4d4wvkkziKmXWcnZjEdahENUAeeFocQ@mail.gmail.com","threadId":"57556","inReplyTo":"xmqqee34m8kz.fsf@gitster.g","subject":"Re: git cherry-pick with --no-verify option","fromName":"Yubin Ruan","fromEmail":"ablacktshirt@gmail.com","sentAt":"2022-03-15T02:29:09Z","receivedAt":"2022-03-15T02:29:25Z","isPatch":false,"sender":{"key":"ablacktshirt@gmail.com","avatar":null},"body":"On Tue, Mar 15, 2022 at 7:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Yubin Ruan <ablacktshirt@gmail.com> writes:\n>\n> > Is there any version of Git that supports the cherry-pick command with\n> > \"--no-verify\"?\n> >\n> > It is supported in \"git commit\" command but not in \"git cherry-pick\"\n> > command, and I always have to move .git/hooks/pre-commit away to work\n> > around this in case of \"git cherry-pick\".\n>\n\n<...>\n\n> Ahh, I think the user is fooled by a bad advice in the message.\n> (all conflicts fixed: run \"git cherry-pick --continue\") is wrong and\n> misleading advice added by those who did not think things through.\n>\n> After fixing all conflicts, run \"git commit\" to record it and then\n> you run \"git cherry-pick --continue\" if there are more steps to\n> cherry-pick (i.e. \"git cherry-pick A..B\").  \"git commit\" takes not\n> just \"--no-verify\" but other options like \"--reset-author\" to let\n> you take over authorship if the conflict resolution (actually,\n> adjusting the original commit to the different context it is being\n> cherry-picked to) is so involved that a change of authorship is\n> warranted.  \"cherry-pick --continue\" does not have all the necessary\n> flexibility and conceptually it is a separte operation (i.e. \"please\n> continue the stopped sequence\" is what it means) from concluding the\n> current step in the sequence.\n\nYes, in case of conflict when doing cherry-pick, \"git commit\" should be used\nto resolve conflict and then \"git cherry-pick --continue\" if necessary.\nThe help message of \"git status\" in the middle of \"git cherry-pick\" is quite\nmisleading.\n\nThanks~\nYubin\n"}]}