merge-ort: basic outline for merge_switch_to_result()

This adds a basic implementation for merge_switch_to_result(), though just in terms of a few new empty functions that will be defined in subsequent commits. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Dec 13, 2020 at 08:04 UTC 9fefce68dc85d96781090f86c067d83f7c50b617
1 file changed +41 -1
merge-ort.c
+41 -1
@@ -971,13 +971,53 @@ static void process_entries(struct merge_options *opt,
971 string_list_clear(&dir_metadata.offsets, 0);
972 }
973
974 +static int checkout(struct merge_options *opt,
975 + struct tree *prev,
976 + struct tree *next)
977 +{
978 + die("Not yet implemented.");
979 +}
980 +
981 +static int record_conflicted_index_entries(struct merge_options *opt,
982 + struct index_state *index,
983 + struct strmap *paths,
984 + struct strmap *conflicted)
985 +{
986 + if (strmap_empty(conflicted))
987 + return 0;
988 +
989 + die("Not yet implemented.");
990 +}
991 +
992 void merge_switch_to_result(struct merge_options *opt,
993 struct tree *head,
994 struct merge_result *result,
995 int update_worktree_and_index,
996 int display_update_msgs)
997 {
980 - die("Not yet implemented");
998 + assert(opt->priv == NULL);
999 + if (result->clean >= 0 && update_worktree_and_index) {
1000 + struct merge_options_internal *opti = result->priv;
1001 +
1002 + if (checkout(opt, head, result->tree)) {
1003 + /* failure to function */
1004 + result->clean = -1;
1005 + return;
1006 + }
1007 +
1008 + if (record_conflicted_index_entries(opt, opt->repo->index,
1009 + &opti->paths,
1010 + &opti->conflicted)) {
1011 + /* failure to function */
1012 + result->clean = -1;
1013 + return;
1014 + }
1015 + }
1016 +
1017 + if (display_update_msgs) {
1018 + /* TODO: print out CONFLICT and other informational messages. */
1019 + }
1020 +
1021 merge_finalize(opt, result);
1022 }
1023