* Writes the diff of the index against HEAD as a patch to the state * directory's "patch" file. */
| 1424 | * directory's "patch" file. |
| 1425 | */ |
| 1426 | static 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 |
no test coverage detected