| 1025 | } |
| 1026 | |
| 1027 | static int do_remerge_diff(struct rev_info *opt, |
| 1028 | struct commit_list *parents, |
| 1029 | struct object_id *oid) |
| 1030 | { |
| 1031 | struct merge_options o; |
| 1032 | struct commit_list *bases = NULL; |
| 1033 | struct merge_result res = {0}; |
| 1034 | struct pretty_print_context ctx = {0}; |
| 1035 | struct commit *parent1 = parents->item; |
| 1036 | struct commit *parent2 = parents->next->item; |
| 1037 | struct strbuf parent1_desc = STRBUF_INIT; |
| 1038 | struct strbuf parent2_desc = STRBUF_INIT; |
| 1039 | |
| 1040 | /* |
| 1041 | * Lazily prepare a temporary object directory and rotate it |
| 1042 | * into the alternative object store list as the primary. |
| 1043 | */ |
| 1044 | if (opt->remerge_diff && !opt->remerge_objdir) { |
| 1045 | opt->remerge_objdir = tmp_objdir_create(the_repository, "remerge-diff"); |
| 1046 | if (!opt->remerge_objdir) |
| 1047 | return error(_("unable to create temporary object directory")); |
| 1048 | tmp_objdir_replace_primary_odb(opt->remerge_objdir, 1); |
| 1049 | } |
| 1050 | |
| 1051 | /* Setup merge options */ |
| 1052 | init_ui_merge_options(&o, the_repository); |
| 1053 | o.show_rename_progress = 0; |
| 1054 | o.record_conflict_msgs_as_headers = 1; |
| 1055 | o.msg_header_prefix = "remerge"; |
| 1056 | |
| 1057 | ctx.abbrev = DEFAULT_ABBREV; |
| 1058 | repo_format_commit_message(the_repository, parent1, "%h (%s)", |
| 1059 | &parent1_desc, &ctx); |
| 1060 | repo_format_commit_message(the_repository, parent2, "%h (%s)", |
| 1061 | &parent2_desc, &ctx); |
| 1062 | o.branch1 = parent1_desc.buf; |
| 1063 | o.branch2 = parent2_desc.buf; |
| 1064 | |
| 1065 | /* Parse the relevant commits and get the merge bases */ |
| 1066 | parse_commit_or_die(parent1); |
| 1067 | parse_commit_or_die(parent2); |
| 1068 | if (repo_get_merge_bases(the_repository, parent1, parent2, &bases) < 0) |
| 1069 | exit(128); |
| 1070 | |
| 1071 | /* Re-merge the parents */ |
| 1072 | merge_incore_recursive(&o, bases, parent1, parent2, &res); |
| 1073 | |
| 1074 | /* Show the diff */ |
| 1075 | setup_additional_headers(&opt->diffopt, res.path_messages); |
| 1076 | diff_tree_oid(&res.tree->object.oid, oid, "", &opt->diffopt); |
| 1077 | log_tree_diff_flush(opt); |
| 1078 | |
| 1079 | /* Cleanup */ |
| 1080 | commit_list_free(bases); |
| 1081 | cleanup_additional_headers(&opt->diffopt); |
| 1082 | strbuf_release(&parent1_desc); |
| 1083 | strbuf_release(&parent2_desc); |
| 1084 | merge_finalize(&o, &res); |
no test coverage detected