Skip to content

Commit 3ac942d

Browse files
peffgitster
authored andcommitted
add inexact rename detection progress infrastructure
We might spend many seconds doing inexact rename detection with no output. It's nice to let the user know that something is actually happening. This patch adds the infrastructure, but no callers actually turn on progress reporting. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 485445e commit 3ac942d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

diff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct diff_options {
111111
int rename_score;
112112
int rename_limit;
113113
int needed_rename_limit;
114+
int show_rename_progress;
114115
int dirstat_percent;
115116
int setup;
116117
int abbrev;

diffcore-rename.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "diff.h"
66
#include "diffcore.h"
77
#include "hash.h"
8+
#include "progress.h"
89

910
/* Table of rename/copy destinations */
1011

@@ -424,6 +425,7 @@ void diffcore_rename(struct diff_options *options)
424425
struct diff_score *mx;
425426
int i, j, rename_count;
426427
int num_create, num_src, dst_cnt;
428+
struct progress *progress = NULL;
427429

428430
if (!minimum_score)
429431
minimum_score = DEFAULT_RENAME_SCORE;
@@ -503,6 +505,12 @@ void diffcore_rename(struct diff_options *options)
503505
goto cleanup;
504506
}
505507

508+
if (options->show_rename_progress) {
509+
progress = start_progress_delay(
510+
"Performing inexact rename detection",
511+
rename_dst_nr * rename_src_nr, 50, 1);
512+
}
513+
506514
mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
507515
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
508516
struct diff_filespec *two = rename_dst[i].two;
@@ -532,7 +540,9 @@ void diffcore_rename(struct diff_options *options)
532540
diff_free_filespec_blob(two);
533541
}
534542
dst_cnt++;
543+
display_progress(progress, (i+1)*rename_src_nr);
535544
}
545+
stop_progress(&progress);
536546

537547
/* cost matrix sorted by most to least similar pair */
538548
qsort(mx, dst_cnt * NUM_CANDIDATE_PER_DST, sizeof(*mx), score_compare);

0 commit comments

Comments
 (0)