merge: improve inexact rename limit warning
The warning is generated deep in the diffcore code, which means that it will come first, followed possibly by a spew of conflicts, making it hard to see. Instead, let's have diffcore pass back the information about how big the rename limit would needed to have been, and then the caller can provide a more appropriate message (and at a more appropriate time). No refactoring of other non-merge callers is necessary, because nobody else was even using the warn_on_rename_limit feature. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 19, 2011 at 05:20 UTC
bf0ab10fa84df6c49450a06077d1c52756d88222
4 files changed
+14
-4
diff.h
+1
-1
@@ -110,7 +110,7 @@ struct diff_options {
110
int pickaxe_opts;
111
int rename_score;
112
int rename_limit;
113
- int warn_on_too_large_rename;
113
+ int needed_rename_limit;
114
int dirstat_percent;
115
int setup;
116
int abbrev;
diffcore-rename.c
+3
-2
@@ -493,12 +493,13 @@ void diffcore_rename(struct diff_options *options)
493
* but handles the potential overflow case specially (and we
494
* assume at least 32-bit integers)
495
*/
496
+ options->needed_rename_limit = 0;
497
if (rename_limit <= 0 || rename_limit > 32767)
498
rename_limit = 32767;
499
if ((num_create > rename_limit && num_src > rename_limit) ||
500
(num_create * num_src > rename_limit * rename_limit)) {
500
- if (options->warn_on_too_large_rename)
501
- warning("too many files (created: %d deleted: %d), skipping inexact rename detection", num_create, num_src);
501
+ options->needed_rename_limit =
502
+ num_src > num_create ? num_src : num_create;
503
goto cleanup;
504
}
505
merge-recursive.c
+9
-1
@@ -22,6 +22,11 @@
22
#include "dir.h"
23
#include "submodule.h"
24
25
+static const char rename_limit_advice[] =
26
+"inexact rename detection was skipped because there were too many\n"
27
+" files. You may want to set your merge.renamelimit variable to at least\n"
28
+" %d and retry this merge.";
29
+
30
static struct tree *shift_tree_object(struct tree *one, struct tree *two,
31
const char *subtree_shift)
32
{
@@ -436,12 +441,13 @@ static struct string_list *get_renames(struct merge_options *o,
441
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
442
500;
443
opts.rename_score = o->rename_score;
439
- opts.warn_on_too_large_rename = 1;
444
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
445
if (diff_setup_done(&opts) < 0)
446
die("diff setup failed");
447
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
448
diffcore_std(&opts);
449
+ if (opts.needed_rename_limit > o->needed_rename_limit)
450
+ o->needed_rename_limit = opts.needed_rename_limit;
451
for (i = 0; i < diff_queued_diff.nr; ++i) {
452
struct string_list_item *item;
453
struct rename *re;
@@ -1666,6 +1672,8 @@ int merge_recursive(struct merge_options *o,
1672
commit_list_insert(h2, &(*result)->parents->next);
1673
}
1674
flush_output(o);
1675
+ if (o->needed_rename_limit)
1676
+ warning(rename_limit_advice, o->needed_rename_limit);
1677
return clean;
1678
}
1679
merge-recursive.h
+1
@@ -20,6 +20,7 @@ struct merge_options {
20
int diff_rename_limit;
21
int merge_rename_limit;
22
int rename_score;
23
+ int needed_rename_limit;
24
int call_depth;
25
struct strbuf obuf;
26
struct string_list current_file_set;