Skip to content

Commit

Permalink
add inexact rename detection progress infrastructure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 21, 2011
1 parent 485445e commit 3ac942d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct diff_options {
int rename_score;
int rename_limit;
int needed_rename_limit;
int show_rename_progress;
int dirstat_percent;
int setup;
int abbrev;
Expand Down
10 changes: 10 additions & 0 deletions diffcore-rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "diff.h"
#include "diffcore.h"
#include "hash.h"
#include "progress.h"

/* Table of rename/copy destinations */

Expand Down Expand Up @@ -424,6 +425,7 @@ void diffcore_rename(struct diff_options *options)
struct diff_score *mx;
int i, j, rename_count;
int num_create, num_src, dst_cnt;
struct progress *progress = NULL;

if (!minimum_score)
minimum_score = DEFAULT_RENAME_SCORE;
Expand Down Expand Up @@ -503,6 +505,12 @@ void diffcore_rename(struct diff_options *options)
goto cleanup;
}

if (options->show_rename_progress) {
progress = start_progress_delay(
"Performing inexact rename detection",
rename_dst_nr * rename_src_nr, 50, 1);
}

mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
struct diff_filespec *two = rename_dst[i].two;
Expand Down Expand Up @@ -532,7 +540,9 @@ void diffcore_rename(struct diff_options *options)
diff_free_filespec_blob(two);
}
dst_cnt++;
display_progress(progress, (i+1)*rename_src_nr);
}
stop_progress(&progress);

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

0 comments on commit 3ac942d

Please sign in to comment.