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

Function write_index_patch

builtin/am.c:1426–1453  ·  view source on GitHub ↗

* Writes the diff of the index against HEAD as a patch to the state * directory's "patch" file. */

Source from the content-addressed store, hash-verified

1424 * directory's "patch" file.
1425 */
1426static void write_index_patch(const struct am_state *state)
1427{
1428 struct tree *tree;
1429 struct object_id head;
1430 struct rev_info rev_info;
1431 FILE *fp;
1432
1433 if (!repo_get_oid(the_repository, "HEAD", &head)) {
1434 struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1435 tree = repo_get_commit_tree(the_repository, commit);
1436 } else
1437 tree = lookup_tree(the_repository,
1438 the_repository->hash_algo->empty_tree);
1439
1440 fp = xfopen(am_path(state, "patch"), "w");
1441 repo_init_revisions(the_repository, &rev_info, NULL);
1442 rev_info.diff = 1;
1443 rev_info.disable_stdin = 1;
1444 rev_info.no_commit_id = 1;
1445 rev_info.diffopt.output_format = DIFF_FORMAT_PATCH;
1446 rev_info.diffopt.use_color = GIT_COLOR_NEVER;
1447 rev_info.diffopt.file = fp;
1448 rev_info.diffopt.close_file = 1;
1449 add_pending_object(&rev_info, &tree->object, "");
1450 diff_setup_done(&rev_info.diffopt);
1451 run_diff_index(&rev_info, DIFF_INDEX_CACHED);
1452 release_revisions(&rev_info);
1453}
1454
1455/**
1456 * Like parse_mail(), but parses the mail by looking up its commit ID

Callers 1

am_resolveFunction · 0.85

Calls 11

repo_get_oidFunction · 0.85
lookup_commit_or_dieFunction · 0.85
repo_get_commit_treeFunction · 0.85
lookup_treeFunction · 0.85
xfopenFunction · 0.85
am_pathFunction · 0.85
repo_init_revisionsFunction · 0.85
add_pending_objectFunction · 0.85
diff_setup_doneFunction · 0.85
run_diff_indexFunction · 0.85
release_revisionsFunction · 0.85

Tested by

no test coverage detected