| 5534 | } |
| 5535 | |
| 5536 | int sequencer_pick_revisions(struct repository *r, |
| 5537 | struct replay_opts *opts) |
| 5538 | { |
| 5539 | struct todo_list todo_list = TODO_LIST_INIT; |
| 5540 | struct object_id oid; |
| 5541 | int i, res; |
| 5542 | |
| 5543 | assert(opts->revs); |
| 5544 | if (read_and_refresh_cache(r, opts)) { |
| 5545 | res = -1; |
| 5546 | goto out; |
| 5547 | } |
| 5548 | |
| 5549 | for (i = 0; i < opts->revs->pending.nr; i++) { |
| 5550 | struct object_id oid; |
| 5551 | const char *name = opts->revs->pending.objects[i].name; |
| 5552 | |
| 5553 | /* This happens when using --stdin. */ |
| 5554 | if (!strlen(name)) |
| 5555 | continue; |
| 5556 | |
| 5557 | if (!repo_get_oid(r, name, &oid)) { |
| 5558 | if (!lookup_commit_reference_gently(r, &oid, 1)) { |
| 5559 | enum object_type type = odb_read_object_info(r->objects, |
| 5560 | &oid, NULL); |
| 5561 | res = error(_("%s: can't cherry-pick a %s"), |
| 5562 | name, type_name(type)); |
| 5563 | goto out; |
| 5564 | } |
| 5565 | } else { |
| 5566 | res = error(_("%s: bad revision"), name); |
| 5567 | goto out; |
| 5568 | } |
| 5569 | } |
| 5570 | |
| 5571 | /* |
| 5572 | * If we were called as "git cherry-pick <commit>", just |
| 5573 | * cherry-pick/revert it, set CHERRY_PICK_HEAD / |
| 5574 | * REVERT_HEAD, and don't touch the sequencer state. |
| 5575 | * This means it is possible to cherry-pick in the middle |
| 5576 | * of a cherry-pick sequence. |
| 5577 | */ |
| 5578 | if (opts->revs->cmdline.nr == 1 && |
| 5579 | opts->revs->cmdline.rev->whence == REV_CMD_REV && |
| 5580 | opts->revs->no_walk && |
| 5581 | !opts->revs->cmdline.rev->flags) { |
| 5582 | struct commit *cmit; |
| 5583 | |
| 5584 | if (prepare_revision_walk(opts->revs)) { |
| 5585 | res = error(_("revision walk setup failed")); |
| 5586 | goto out; |
| 5587 | } |
| 5588 | |
| 5589 | cmit = get_revision(opts->revs); |
| 5590 | if (!cmit) { |
| 5591 | res = error(_("empty commit set passed")); |
| 5592 | goto out; |
| 5593 | } |
no test coverage detected