From 66f136252fe1998e2c1381c913795b5f56b6dc8c Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 15 Dec 2010 22:02:38 +0700 Subject: Convert struct diff_options to use struct pathspec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 0083d92438..310bd6b283 100644 --- a/diff.h +++ b/diff.h @@ -133,9 +133,7 @@ struct diff_options { FILE *file; int close_file; - int nr_paths; - const char **paths; - int *pathlens; + struct pathspec pathspec; change_fn_t change; add_remove_fn_t add_remove; diff_format_fn_t format_callback; -- cgit v1.3 From bf0ab10fa84df6c49450a06077d1c52756d88222 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 19 Feb 2011 05:20:51 -0500 Subject: 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 Signed-off-by: Junio C Hamano --- diff.h | 2 +- diffcore-rename.c | 5 +++-- merge-recursive.c | 10 +++++++++- merge-recursive.h | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 0083d92438..f774c9ab51 100644 --- a/diff.h +++ b/diff.h @@ -110,7 +110,7 @@ struct diff_options { int pickaxe_opts; int rename_score; int rename_limit; - int warn_on_too_large_rename; + int needed_rename_limit; int dirstat_percent; int setup; int abbrev; diff --git a/diffcore-rename.c b/diffcore-rename.c index df41be56de..1943c46b94 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -493,12 +493,13 @@ 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; } diff --git a/merge-recursive.c b/merge-recursive.c index 16c2dbeab9..2ecd456c28 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -22,6 +22,11 @@ #include "dir.h" #include "submodule.h" +static const char rename_limit_advice[] = +"inexact rename detection was skipped because there were too many\n" +" files. You may want to set your merge.renamelimit variable to at least\n" +" %d and retry this merge."; + static struct tree *shift_tree_object(struct tree *one, struct tree *two, const char *subtree_shift) { @@ -436,12 +441,13 @@ static struct string_list *get_renames(struct merge_options *o, o->diff_rename_limit >= 0 ? o->diff_rename_limit : 500; opts.rename_score = o->rename_score; - opts.warn_on_too_large_rename = 1; opts.output_format = DIFF_FORMAT_NO_OUTPUT; if (diff_setup_done(&opts) < 0) die("diff setup failed"); diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts); diffcore_std(&opts); + if (opts.needed_rename_limit > o->needed_rename_limit) + o->needed_rename_limit = opts.needed_rename_limit; for (i = 0; i < diff_queued_diff.nr; ++i) { struct string_list_item *item; struct rename *re; @@ -1666,6 +1672,8 @@ int merge_recursive(struct merge_options *o, commit_list_insert(h2, &(*result)->parents->next); } flush_output(o); + if (o->needed_rename_limit) + warning(rename_limit_advice, o->needed_rename_limit); return clean; } diff --git a/merge-recursive.h b/merge-recursive.h index c8135b0ec7..f0e056652f 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -20,6 +20,7 @@ struct merge_options { int diff_rename_limit; int merge_rename_limit; int rename_score; + int needed_rename_limit; int call_depth; struct strbuf obuf; struct string_list current_file_set; -- cgit v1.3 From 3ac942d42ebb1fb48e70d3e5a714d06396e3e2c6 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 20 Feb 2011 04:51:16 -0500 Subject: 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 Signed-off-by: Junio C Hamano --- diff.h | 1 + diffcore-rename.c | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index f774c9ab51..9585e41aea 100644 --- a/diff.h +++ b/diff.h @@ -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; diff --git a/diffcore-rename.c b/diffcore-rename.c index 1943c46b94..cb57f51272 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -5,6 +5,7 @@ #include "diff.h" #include "diffcore.h" #include "hash.h" +#include "progress.h" /* Table of rename/copy destinations */ @@ -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; @@ -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; @@ -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); -- cgit v1.3