@@ -209,6 +209,16 @@ struct conflict_info {
209
209
assert((ci) && !(mi)->clean); \
210
210
} while (0)
211
211
212
+ static void free_strmap_strings (struct strmap * map )
213
+ {
214
+ struct hashmap_iter iter ;
215
+ struct strmap_entry * entry ;
216
+
217
+ strmap_for_each_entry (map , & iter , entry ) {
218
+ free ((char * )entry -> key );
219
+ }
220
+ }
221
+
212
222
static int err (struct merge_options * opt , const char * err , ...)
213
223
{
214
224
va_list params ;
@@ -1153,7 +1163,27 @@ void merge_switch_to_result(struct merge_options *opt,
1153
1163
void merge_finalize (struct merge_options * opt ,
1154
1164
struct merge_result * result )
1155
1165
{
1156
- die ("Not yet implemented" );
1166
+ struct merge_options_internal * opti = result -> priv ;
1167
+
1168
+ assert (opt -> priv == NULL );
1169
+
1170
+ /*
1171
+ * We marked opti->paths with strdup_strings = 0, so that we
1172
+ * wouldn't have to make another copy of the fullpath created by
1173
+ * make_traverse_path from setup_path_info(). But, now that we've
1174
+ * used it and have no other references to these strings, it is time
1175
+ * to deallocate them.
1176
+ */
1177
+ free_strmap_strings (& opti -> paths );
1178
+ strmap_clear (& opti -> paths , 1 );
1179
+
1180
+ /*
1181
+ * All keys and values in opti->conflicted are a subset of those in
1182
+ * opti->paths. We don't want to deallocate anything twice, so we
1183
+ * don't free the keys and we pass 0 for free_values.
1184
+ */
1185
+ strmap_clear (& opti -> conflicted , 0 );
1186
+ FREE_AND_NULL (opti );
1157
1187
}
1158
1188
1159
1189
static void merge_start (struct merge_options * opt , struct merge_result * result )
0 commit comments