{"thread":{"id":"34855","subject":"[PATCH v2] cherry-pick: allow \"-\" as abbreviation of '@{-1}'","startedAt":"2013-09-05T14:57:23Z","lastAt":"2013-09-05T22:30:03Z","messageCount":2,"participants":["Hiroshige Umino","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"226851","messageId":"1378393043-55403-1-git-send-email-hiroshige88@gmail.com","threadId":"34855","inReplyTo":null,"subject":"[PATCH v2] cherry-pick: allow \"-\" as abbreviation of '@{-1}'","fromName":"Hiroshige Umino","fromEmail":"hiroshige88@gmail.com","sentAt":"2013-09-05T14:57:23Z","receivedAt":"2013-09-05T14:57:23Z","isPatch":true,"sender":{"key":"hiroshige88@gmail.com","avatar":"https://avatars.githubusercontent.com/u/18807?v=4"},"body":"\"-\" abbreviation is handy for \"cherry-pick\" like \"checkout\" and \"merge\".\n\nIt's also good for uniformity that a \"-\" stands as\nthe name of the previous branch where a branch name is\naccepted and it could not mean any other things like stdin.\n\nSigned-off-by: Hiroshige Umino <hiroshige88@gmail.com>\n---\n builtin/revert.c  |  2 ++\n t/t3500-cherry.sh | 15 +++++++++++++++\n 2 files changed, 17 insertions(+)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 8e87acd..52c35e7 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -202,6 +202,8 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)\n \tmemset(&opts, 0, sizeof(opts));\n \topts.action = REPLAY_PICK;\n \tgit_config(git_default_config, NULL);\n+\tif (!strcmp(argv[1], \"-\"))\n+\t\targv[1] = \"@{-1}\";\n \tparse_args(argc, argv, &opts);\n \tres = sequencer_pick_revisions(&opts);\n \tif (res < 0)\ndiff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh\nindex f038f34..547dbf8 100755\n--- a/t/t3500-cherry.sh\n+++ b/t/t3500-cherry.sh\n@@ -55,4 +55,19 @@ test_expect_success \\\n      expr \"$(echo $(git cherry master my-topic-branch) )\" : \"+ [^ ]* - .*\"\n '\n \n+test_expect_success \\\n+    '\"cherry-pick -\" does not work initially' \\\n+    'test_must_fail git cherry-pick -\n+'\n+\n+test_expect_success \\\n+    'cherry-pick the commit in the previous branch' \\\n+    'git branch other &&\n+     test_commit commit-to-pick newfile content &&\n+     echo content >expected &&\n+     git checkout other &&\n+     git cherry-pick - &&\n+     test_cmp expected newfile\n+'\n+\n test_done\n-- \n1.8.3.4\n"},{"id":"226889","messageId":"xmqq4n9yhpg4.fsf@gitster.dls.corp.google.com","threadId":"34855","inReplyTo":"1378393043-55403-1-git-send-email-hiroshige88@gmail.com","subject":"Re: [PATCH v2] cherry-pick: allow \"-\" as abbreviation of '@{-1}'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-05T22:30:03Z","receivedAt":"2013-09-05T22:30:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Hiroshige Umino <hiroshige88@gmail.com> writes:\n\n> \"-\" abbreviation is handy for \"cherry-pick\" like \"checkout\" and \"merge\".\n>\n> It's also good for uniformity that a \"-\" stands as\n> the name of the previous branch where a branch name is\n> accepted and it could not mean any other things like stdin.\n>\n> Signed-off-by: Hiroshige Umino <hiroshige88@gmail.com>\n> ---\n\nThis makes sense to me.\n\nThe test t3500 is about \"git cherry\" command, so I came up with a\ntweak to move it to t3501, which is about cherry-pick, on top of\nthis patch.  Will tentatively queue this patch with that tweak to\n'pu'.\n\nThanks.\n\n>  builtin/revert.c  |  2 ++\n>  t/t3500-cherry.sh | 15 +++++++++++++++\n>  2 files changed, 17 insertions(+)\n>\n> diff --git a/builtin/revert.c b/builtin/revert.c\n> index 8e87acd..52c35e7 100644\n> --- a/builtin/revert.c\n> +++ b/builtin/revert.c\n> @@ -202,6 +202,8 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)\n>  \tmemset(&opts, 0, sizeof(opts));\n>  \topts.action = REPLAY_PICK;\n>  \tgit_config(git_default_config, NULL);\n> +\tif (!strcmp(argv[1], \"-\"))\n> +\t\targv[1] = \"@{-1}\";\n>  \tparse_args(argc, argv, &opts);\n>  \tres = sequencer_pick_revisions(&opts);\n>  \tif (res < 0)\n> diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh\n> index f038f34..547dbf8 100755\n> --- a/t/t3500-cherry.sh\n> +++ b/t/t3500-cherry.sh\n> @@ -55,4 +55,19 @@ test_expect_success \\\n>       expr \"$(echo $(git cherry master my-topic-branch) )\" : \"+ [^ ]* - .*\"\n>  '\n>  \n> +test_expect_success \\\n> +    '\"cherry-pick -\" does not work initially' \\\n> +    'test_must_fail git cherry-pick -\n> +'\n> +\n> +test_expect_success \\\n> +    'cherry-pick the commit in the previous branch' \\\n> +    'git branch other &&\n> +     test_commit commit-to-pick newfile content &&\n> +     echo content >expected &&\n> +     git checkout other &&\n> +     git cherry-pick - &&\n> +     test_cmp expected newfile\n> +'\n> +\n>  test_done\n"}]}