diff options
-rw-r--r-- | builtin/revert.c | 2 | ||||
-rwxr-xr-x | t/t3501-revert-cherry-pick.sh | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/builtin/revert.c b/builtin/revert.c index 8e87acd12e..52c35e75d9 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -202,6 +202,8 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix) memset(&opts, 0, sizeof(opts)); opts.action = REPLAY_PICK; git_config(git_default_config, NULL); + if (!strcmp(argv[1], "-")) + argv[1] = "@{-1}"; parse_args(argc, argv, &opts); res = sequencer_pick_revisions(&opts); if (res < 0) diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 46aaf2f511..bff6ffe088 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -109,4 +109,24 @@ test_expect_success 'cherry-pick on unborn branch' ' ! test_cmp_rev initial HEAD ' +test_expect_success 'cherry-pick "-" to pick from previous branch' ' + git checkout unborn && + test_commit to-pick actual content && + git checkout master && + git cherry-pick - && + echo content >expect && + test_cmp expect actual +' + +test_expect_success 'cherry-pick "-" is meaningless without checkout' ' + test_create_repo afresh && + ( + cd afresh && + test_commit one && + test_commit two && + test_commit three && + test_must_fail git cherry-pick - + ) +' + test_done |