merge-recursive: New data structures for deferring of D/F conflicts
Since we need to resolve paths (including renames) in-core first and defer checking of D/F conflicts (namely waiting to see if directories are still in the way after all paths are resolved) before updating files involved in D/F conflicts, we will need to first process_renames, then record some information about the rename needed at D/F resolution time, and then make use of that information when resolving D/F conflicts at the end. This commit adds some relevant data structures for storing the necessary information. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Sep 20, 2010 at 02:28 UTC
25c3936349ba052f0c7e9ba3ce138b89abcae6ee
1 file changed
+44
merge-recursive.c
+44
@@ -63,6 +63,22 @@ static int sha_eq(const unsigned char *a, const unsigned char *b)
63
return a && b && hashcmp(a, b) == 0;
64
}
65
66
+enum rename_type {
67
+ RENAME_NORMAL = 0,
68
+ RENAME_DELETE,
69
+ RENAME_ONE_FILE_TO_TWO
70
+};
71
+
72
+struct rename_df_conflict_info {
73
+ enum rename_type rename_type;
74
+ struct diff_filepair *pair1;
75
+ struct diff_filepair *pair2;
76
+ const char *branch1;
77
+ const char *branch2;
78
+ struct stage_data *dst_entry1;
79
+ struct stage_data *dst_entry2;
80
+};
81
+
82
/*
83
* Since we want to write the index eventually, we cannot reuse the index
84
* for these (temporary) data.
@@ -74,9 +90,37 @@ struct stage_data
90
unsigned mode;
91
unsigned char sha[20];
92
} stages[4];
93
+ struct rename_df_conflict_info *rename_df_conflict_info;
94
unsigned processed:1;
95
};
96
97
+static inline void setup_rename_df_conflict_info(enum rename_type rename_type,
98
+ struct diff_filepair *pair1,
99
+ struct diff_filepair *pair2,
100
+ const char *branch1,
101
+ const char *branch2,
102
+ struct stage_data *dst_entry1,
103
+ struct stage_data *dst_entry2)
104
+{
105
+ struct rename_df_conflict_info *ci = xcalloc(1, sizeof(struct rename_df_conflict_info));
106
+ ci->rename_type = rename_type;
107
+ ci->pair1 = pair1;
108
+ ci->branch1 = branch1;
109
+ ci->branch2 = branch2;
110
+
111
+ ci->dst_entry1 = dst_entry1;
112
+ dst_entry1->rename_df_conflict_info = ci;
113
+ dst_entry1->processed = 0;
114
+
115
+ assert(!pair2 == !dst_entry2);
116
+ if (dst_entry2) {
117
+ ci->dst_entry2 = dst_entry2;
118
+ ci->pair2 = pair2;
119
+ dst_entry2->rename_df_conflict_info = ci;
120
+ dst_entry2->processed = 0;
121
+ }
122
+}
123
+
124
static int show(struct merge_options *o, int v)
125
{
126
return (!o->call_depth && o->verbosity >= v) || o->verbosity >= 5;