{"thread":{"id":"29687","subject":"[PATCH v2] cherry-pick: No advice to commit if --no-commit","startedAt":"2012-02-22T00:44:17Z","lastAt":"2012-02-22T00:51:33Z","messageCount":2,"participants":["Phil Hord","Jonathan Nieder"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"185124","messageId":"1329871457-12890-1-git-send-email-hordp@cisco.com","threadId":"29687","inReplyTo":null,"subject":"[PATCH v2] cherry-pick: No advice to commit if --no-commit","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-02-22T00:44:17Z","receivedAt":"2012-02-22T00:44:17Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"When cherry-pick fails it offers a helpful hint about how to\nproceed.  The hint tells the user how to do the cleanup\nneeded by the conflicted cherry-pick and finish the job after\nconflict resolution.  In case of cherry-pick --no-commit, the\nhint goes too far. It tells the user to finish up with\n'git commit'.  That is not what this git-cherry-pick was\ntrying to do in the first place.\n\nRestrict the hint in case of --no-commit to avoid giving this\nextra advice.\n\nAlso, add a test verifying the reduced hint for the --no-commit\nversion of cherry-pick.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n sequencer.c                     |   17 +++++++++++------\n t/t3507-cherry-pick-conflict.sh |   14 ++++++++++++++\n 2 files changed, 25 insertions(+), 6 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 5fcbcb8..9716c63 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -123,7 +123,7 @@ static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)\n \tstrbuf_release(&buf);\n }\n \n-static void print_advice(int show_hint)\n+static void print_advice(int show_hint, struct replay_opts *opts)\n {\n \tchar *msg = getenv(\"GIT_CHERRY_PICK_HELP\");\n \n@@ -138,10 +138,15 @@ static void print_advice(int show_hint)\n \t\treturn;\n \t}\n \n-\tif (show_hint)\n-\t\tadvise(_(\"after resolving the conflicts, mark the corrected paths\\n\"\n-\t\t\t \"with 'git add <paths>' or 'git rm <paths>'\\n\"\n-\t\t\t \"and commit the result with 'git commit'\"));\n+\tif (show_hint) {\n+\t\tif (opts->no_commit)\n+\t\t\tadvise(_(\"after resolving the conflicts, mark the corrected paths\\n\"\n+\t\t\t\t \"with 'git add <paths>' or 'git rm <paths>'\"));\n+\t\telse\n+\t\t\tadvise(_(\"after resolving the conflicts, mark the corrected paths\\n\"\n+\t\t\t\t \"with 'git add <paths>' or 'git rm <paths>'\\n\"\n+\t\t\t\t \"and commit the result with 'git commit'\"));\n+    }\n }\n \n static void write_message(struct strbuf *msgbuf, const char *filename)\n@@ -423,7 +428,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)\n \t\t      : _(\"could not apply %s... %s\"),\n \t\t      find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),\n \t\t      msg.subject);\n-\t\tprint_advice(res == 1);\n+\t\tprint_advice(res == 1, opts);\n \t\trerere(opts->allow_rerere_auto);\n \t} else {\n \t\tif (!opts->no_commit)\ndiff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh\nindex ee1659c..0c81b3c 100755\n--- a/t/t3507-cherry-pick-conflict.sh\n+++ b/t/t3507-cherry-pick-conflict.sh\n@@ -59,6 +59,20 @@ test_expect_success 'advice from failed cherry-pick' \"\n \ttest_i18ncmp expected actual\n \"\n \n+test_expect_success 'advice from failed cherry-pick --no-commit' \"\n+\tpristine_detach initial &&\n+\n+\tpicked=\\$(git rev-parse --short picked) &&\n+\tcat <<-EOF >expected &&\n+\terror: could not apply \\$picked... picked\n+\thint: after resolving the conflicts, mark the corrected paths\n+\thint: with 'git add <paths>' or 'git rm <paths>'\n+\tEOF\n+\ttest_must_fail git cherry-pick --no-commit picked 2>actual &&\n+\n+\ttest_i18ncmp expected actual\n+\"\n+\n test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '\n \tpristine_detach initial &&\n \ttest_must_fail git cherry-pick picked &&\n-- \n1.7.9.267.gda172.dirty\n"},{"id":"185126","messageId":"20120222005133.GC31934@burratino","threadId":"29687","inReplyTo":"1329871457-12890-1-git-send-email-hordp@cisco.com","subject":"Re: [PATCH v2] cherry-pick: No advice to commit if --no-commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-02-22T00:51:33Z","receivedAt":"2012-02-22T00:51:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Phil Hord wrote:\n\n>                       In case of cherry-pick --no-commit, the\n> hint goes too far. It tells the user to finish up with\n> 'git commit'.  That is not what this git-cherry-pick was\n> trying to do in the first place.\n\nEspecially since if I do try to commit as it says, it will not\nreuse the old commit message and timestamp like the advice made me\nsuspect it would. :)\n\n[...]\n> --- a/t/t3507-cherry-pick-conflict.sh\n> +++ b/t/t3507-cherry-pick-conflict.sh\n> @@ -59,6 +59,20 @@ test_expect_success 'advice from failed cherry-pick' \"\n>  \ttest_i18ncmp expected actual\n>  \"\n>  \n> +test_expect_success 'advice from failed cherry-pick --no-commit' \"\n> +\tpristine_detach initial &&\n> +\n> +\tpicked=\\$(git rev-parse --short picked) &&\n\nThe escaping here is obnoxiously tricky.  Not your fault, though.\n\nFor what it's worth,\nAcked-by: Jonathan Nieder <jrnieder@gmail.com>\n\nThanks.\n"}]}