MCPcopy Index your code
hub / github.com/git/git / sequencer_pick_revisions

Function sequencer_pick_revisions

sequencer.c:5536–5635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5534}
5535
5536int 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 }

Callers 1

run_sequencerFunction · 0.85

Calls 15

read_and_refresh_cacheFunction · 0.85
repo_get_oidFunction · 0.85
odb_read_object_infoFunction · 0.85
errorFunction · 0.85
type_nameFunction · 0.85
prepare_revision_walkFunction · 0.85
get_revisionFunction · 0.85
single_pickFunction · 0.85
walk_revs_populate_todoFunction · 0.85
create_seq_dirFunction · 0.85
save_headFunction · 0.85

Tested by

no test coverage detected