MCPcopy Create free account
hub / github.com/git/git / skip_unnecessary_picks

Function skip_unnecessary_picks

sequencer.c:6389–6434  ·  view source on GitHub ↗

skip picking commits whose parents are unchanged */

Source from the content-addressed store, hash-verified

6387
6388/* skip picking commits whose parents are unchanged */
6389static int skip_unnecessary_picks(struct repository *r,
6390 struct todo_list *todo_list,
6391 struct object_id *base_oid)
6392{
6393 struct object_id *parent_oid;
6394 int i;
6395
6396 for (i = 0; i < todo_list->nr; i++) {
6397 struct todo_item *item = todo_list->items + i;
6398
6399 if (item->command >= TODO_NOOP)
6400 continue;
6401 if (item->command != TODO_PICK)
6402 break;
6403 if (repo_parse_commit(r, item->commit)) {
6404 return error(_("could not parse commit '%s'"),
6405 oid_to_hex(&item->commit->object.oid));
6406 }
6407 if (!item->commit->parents)
6408 break; /* root commit */
6409 if (item->commit->parents->next)
6410 break; /* merge commit */
6411 parent_oid = &item->commit->parents->item->object.oid;
6412 if (!oideq(parent_oid, base_oid))
6413 break;
6414 oidcpy(base_oid, &item->commit->object.oid);
6415 }
6416 if (i > 0) {
6417 const char *done_path = rebase_path_done();
6418
6419 if (todo_list_write_to_file(r, todo_list, done_path, NULL, NULL, i, 0)) {
6420 error_errno(_("could not write to '%s'"), done_path);
6421 return -1;
6422 }
6423
6424 MOVE_ARRAY(todo_list->items, todo_list->items + i, todo_list->nr - i);
6425 todo_list->nr -= i;
6426 todo_list->current = 0;
6427 todo_list->done_nr += i;
6428
6429 if (is_fixup(peek_command(todo_list, 0)))
6430 record_in_rewritten(base_oid, peek_command(todo_list, 0));
6431 }
6432
6433 return 0;
6434}
6435
6436struct todo_add_branch_context {
6437 struct todo_item *items;

Callers 1

complete_actionFunction · 0.85

Calls 10

repo_parse_commitFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
oideqFunction · 0.85
oidcpyFunction · 0.85
todo_list_write_to_fileFunction · 0.85
error_errnoFunction · 0.85
is_fixupFunction · 0.85
peek_commandFunction · 0.85
record_in_rewrittenFunction · 0.85

Tested by

no test coverage detected