@@ -388,28 +388,28 @@ static void dirname_munge(char *filename)
388
388
* slash = '\0' ;
389
389
}
390
390
391
- static void increment_count (struct strmap * dir_rename_count ,
391
+ static void increment_count (struct dir_rename_info * info ,
392
392
char * old_dir ,
393
393
char * new_dir )
394
394
{
395
395
struct strintmap * counts ;
396
396
struct strmap_entry * e ;
397
397
398
398
/* Get the {new_dirs -> counts} mapping using old_dir */
399
- e = strmap_get_entry (dir_rename_count , old_dir );
399
+ e = strmap_get_entry (info -> dir_rename_count , old_dir );
400
400
if (e ) {
401
401
counts = e -> value ;
402
402
} else {
403
403
counts = xmalloc (sizeof (* counts ));
404
404
strintmap_init_with_options (counts , 0 , NULL , 1 );
405
- strmap_put (dir_rename_count , old_dir , counts );
405
+ strmap_put (info -> dir_rename_count , old_dir , counts );
406
406
}
407
407
408
408
/* Increment the count for new_dir */
409
409
strintmap_incr (counts , new_dir , 1 );
410
410
}
411
411
412
- static void update_dir_rename_counts (struct strmap * dir_rename_count ,
412
+ static void update_dir_rename_counts (struct dir_rename_info * info ,
413
413
struct strset * dirs_removed ,
414
414
const char * oldname ,
415
415
const char * newname )
@@ -463,7 +463,7 @@ static void update_dir_rename_counts(struct strmap *dir_rename_count,
463
463
}
464
464
465
465
if (strset_contains (dirs_removed , old_dir ))
466
- increment_count (dir_rename_count , old_dir , new_dir );
466
+ increment_count (info , old_dir , new_dir );
467
467
else
468
468
break ;
469
469
@@ -479,12 +479,15 @@ static void update_dir_rename_counts(struct strmap *dir_rename_count,
479
479
free (new_dir );
480
480
}
481
481
482
- static void compute_dir_rename_counts (struct strmap * dir_rename_count ,
483
- struct strset * dirs_removed )
482
+ static void compute_dir_rename_counts (struct dir_rename_info * info ,
483
+ struct strset * dirs_removed ,
484
+ struct strmap * dir_rename_count )
484
485
{
485
486
int i ;
486
487
487
- /* Set up dir_rename_count */
488
+ info -> setup = 1 ;
489
+ info -> dir_rename_count = dir_rename_count ;
490
+
488
491
for (i = 0 ; i < rename_dst_nr ; ++ i ) {
489
492
/* File not part of directory rename counts if not a rename */
490
493
if (!rename_dst [i ].is_rename )
@@ -497,7 +500,7 @@ static void compute_dir_rename_counts(struct strmap *dir_rename_count,
497
500
* the old filename and the new filename and count how many
498
501
* times that pairing occurs.
499
502
*/
500
- update_dir_rename_counts (dir_rename_count , dirs_removed ,
503
+ update_dir_rename_counts (info , dirs_removed ,
501
504
rename_dst [i ].p -> one -> path ,
502
505
rename_dst [i ].p -> two -> path );
503
506
}
@@ -551,7 +554,9 @@ static void cleanup_dir_rename_info(struct dir_rename_info *info)
551
554
/* dir_rename_guess */
552
555
strmap_clear (& info -> dir_rename_guess , 1 );
553
556
554
- /* Nothing to do for dir_rename_count, yet */
557
+ /* dir_rename_count */
558
+ partial_clear_dir_rename_count (info -> dir_rename_count );
559
+ strmap_clear (info -> dir_rename_count , 1 );
555
560
}
556
561
557
562
static const char * get_basename (const char * filename )
@@ -1140,7 +1145,7 @@ void diffcore_rename_extended(struct diff_options *options,
1140
1145
/*
1141
1146
* Now that renames have been computed, compute dir_rename_count */
1142
1147
if (dirs_removed && dir_rename_count )
1143
- compute_dir_rename_counts (dir_rename_count , dirs_removed );
1148
+ compute_dir_rename_counts (& info , dirs_removed , dir_rename_count );
1144
1149
1145
1150
/* At this point, we have found some renames and copies and they
1146
1151
* are recorded in rename_dst. The original list is still in *q.
0 commit comments