1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-26 15:16:09 +02:00

Merge branch 'hu/cherry-pick-previous-branch'

Just like "git checkout -" knows to check out and "git merge -"
knows to merge the branch you were previously on, "git cherry-pick"
now understands "git cherry-pick -" to pick from the previous
branch.

* hu/cherry-pick-previous-branch:
  cherry-pick: allow "-" as abbreviation of '@{-1}'
This commit is contained in:
Junio C Hamano 2013-09-20 12:29:57 -07:00
commit 08092082b7
2 changed files with 22 additions and 0 deletions

View File

@ -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)

View File

@ -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