Code

Merge branch 'jn/maint-format-patch-doc' into maint
[git.git] / diffcore-rename.c
index 0cd4c1305ba82b39bb8455dd6779fec2cd692e02..0b9e99a04ee62d0d14900888f5b8b9ab3d957b5f 100644 (file)
@@ -5,6 +5,7 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "hash.h"
+#include "progress.h"
 
 /* Table of rename/copy destinations */
 
@@ -449,6 +450,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;
@@ -464,7 +466,7 @@ void diffcore_rename(struct diff_options *options)
                        else
                                locate_rename_dst(p->two, 1);
                }
-               else if (!DIFF_FILE_VALID(p->two)) {
+               else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {
                        /*
                         * If the source is a broken "delete", and
                         * they did not really want to get broken,
@@ -518,15 +520,22 @@ void diffcore_rename(struct diff_options *options)
         * but handles the potential overflow case specially (and we
         * assume at least 32-bit integers)
         */
+       options->needed_rename_limit = 0;
        if (rename_limit <= 0 || rename_limit > 32767)
                rename_limit = 32767;
        if ((num_create > rename_limit && num_src > rename_limit) ||
            (num_create * num_src > rename_limit * rename_limit)) {
-               if (options->warn_on_too_large_rename)
-                       warning("too many files (created: %d deleted: %d), skipping inexact rename detection", num_create, num_src);
+               options->needed_rename_limit =
+                       num_src > num_create ? num_src : num_create;
                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;
@@ -556,7 +565,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);
@@ -575,7 +586,10 @@ void diffcore_rename(struct diff_options *options)
                struct diff_filepair *p = q->queue[i];
                struct diff_filepair *pair_to_free = NULL;
 
-               if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+               if (DIFF_PAIR_UNMERGED(p)) {
+                       diff_q(&outq, p);
+               }
+               else if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
                        /*
                         * Creation
                         *