@matheusbsbs / matheus-bagliano / commits / 4c4caafc9c
Fork 0

Treat D/F conflict entry more carefully in unpack-trees.c::threeway_merge()

This fixes three buglets in threeway_merge() regarding D/F conflict entries. * After finishing with path D and handling path D/F, some stages have D/F conflict entry which are obviously non-NULL. For the purpose of determining if the path D/F is missing in the ancestor, they should not be taken into account. * D/F conflict entry is a marker to say "this stage does _not_ have the path", so do not send them to keep_entry(). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 7, 2007 at 05:49 UTC 4c4caafc9cef1031beb46babe9adfdcc03f3cd52
1 file changed +20 -14
unpack-trees.c
+20 -14
@@ -665,7 +665,6 @@ int threeway_merge(struct cache_entry **stages,
665 int count;
666 int head_match = 0;
667 int remote_match = 0;
668 - const char *path = NULL;
668
669 int df_conflict_head = 0;
670 int df_conflict_remote = 0;
@@ -675,13 +674,10 @@ int threeway_merge(struct cache_entry **stages,
674 int i;
675
676 for (i = 1; i < o->head_idx; i++) {
678 - if (!stages[i])
677 + if (!stages[i] || stages[i] == o->df_conflict_entry)
678 any_anc_missing = 1;
680 - else {
681 - if (!path)
682 - path = stages[i]->name;
679 + else
680 no_anc_exists = 0;
684 - }
681 }
682
683 index = stages[0];
@@ -697,13 +693,6 @@ int threeway_merge(struct cache_entry **stages,
693 remote = NULL;
694 }
695
700 - if (!path && index)
701 - path = index->name;
702 - if (!path && head)
703 - path = head->name;
704 - if (!path && remote)
705 - path = remote->name;
706 -
696 /* First, if there's a #16 situation, note that to prevent #13
697 * and #14.
698 */
@@ -755,6 +744,23 @@ int threeway_merge(struct cache_entry **stages,
744 if (o->aggressive) {
745 int head_deleted = !head && !df_conflict_head;
746 int remote_deleted = !remote && !df_conflict_remote;
747 + const char *path = NULL;
748 +
749 + if (index)
750 + path = index->name;
751 + else if (head)
752 + path = head->name;
753 + else if (remote)
754 + path = remote->name;
755 + else {
756 + for (i = 1; i < o->head_idx; i++) {
757 + if (stages[i] && stages[i] != o->df_conflict_entry) {
758 + path = stages[i]->name;
759 + break;
760 + }
761 + }
762 + }
763 +
764 /*
765 * Deleted in both.
766 * Deleted in one and unchanged in the other.
@@ -790,7 +796,7 @@ int threeway_merge(struct cache_entry **stages,
796 count = 0;
797 if (!head_match || !remote_match) {
798 for (i = 1; i < o->head_idx; i++) {
793 - if (stages[i]) {
799 + if (stages[i] && stages[i] != o->df_conflict_entry) {
800 keep_entry(stages[i], o);
801 count++;
802 break;