@@ -308,8 +308,12 @@ static void free_strmap_strings(struct strmap *map)
308
308
static void clear_or_reinit_internal_opts (struct merge_options_internal * opti ,
309
309
int reinitialize )
310
310
{
311
+ struct rename_info * renames = & opti -> renames ;
312
+ int i ;
311
313
void (* strmap_func )(struct strmap * , int ) =
312
314
reinitialize ? strmap_partial_clear : strmap_clear ;
315
+ void (* strset_func )(struct strset * ) =
316
+ reinitialize ? strset_partial_clear : strset_clear ;
313
317
314
318
/*
315
319
* We marked opti->paths with strdup_strings = 0, so that we
@@ -339,6 +343,23 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
339
343
string_list_clear (& opti -> paths_to_free , 0 );
340
344
opti -> paths_to_free .strdup_strings = 0 ;
341
345
346
+ /* Free memory used by various renames maps */
347
+ for (i = MERGE_SIDE1 ; i <= MERGE_SIDE2 ; ++ i ) {
348
+ struct hashmap_iter iter ;
349
+ struct strmap_entry * entry ;
350
+
351
+ strset_func (& renames -> dirs_removed [i ]);
352
+
353
+ strmap_for_each_entry (& renames -> dir_rename_count [i ],
354
+ & iter , entry ) {
355
+ struct strintmap * counts = entry -> value ;
356
+ strintmap_clear (counts );
357
+ }
358
+ strmap_func (& renames -> dir_rename_count [i ], 1 );
359
+
360
+ strmap_func (& renames -> dir_renames [i ], 0 );
361
+ }
362
+
342
363
if (!reinitialize ) {
343
364
struct hashmap_iter iter ;
344
365
struct strmap_entry * e ;
@@ -1812,6 +1833,9 @@ static struct commit *make_virtual_commit(struct repository *repo,
1812
1833
1813
1834
static void merge_start (struct merge_options * opt , struct merge_result * result )
1814
1835
{
1836
+ struct rename_info * renames ;
1837
+ int i ;
1838
+
1815
1839
/* Sanity checks on opt */
1816
1840
assert (opt -> repo );
1817
1841
@@ -1846,6 +1870,17 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
1846
1870
/* Initialization of opt->priv, our internal merge data */
1847
1871
opt -> priv = xcalloc (1 , sizeof (* opt -> priv ));
1848
1872
1873
+ /* Initialization of various renames fields */
1874
+ renames = & opt -> priv -> renames ;
1875
+ for (i = MERGE_SIDE1 ; i <= MERGE_SIDE2 ; i ++ ) {
1876
+ strset_init_with_options (& renames -> dirs_removed [i ],
1877
+ NULL , 0 );
1878
+ strmap_init_with_options (& renames -> dir_rename_count [i ],
1879
+ NULL , 1 );
1880
+ strmap_init_with_options (& renames -> dir_renames [i ],
1881
+ NULL , 0 );
1882
+ }
1883
+
1849
1884
/*
1850
1885
* Although we initialize opt->priv->paths with strdup_strings=0,
1851
1886
* that's just to avoid making yet another copy of an allocated
0 commit comments