1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-13 13:26:08 +02:00

Merge branch 'jk/merge-rename-ux'

* jk/merge-rename-ux:
  pull: propagate --progress to merge
  merge: enable progress reporting for rename detection
  add inexact rename detection progress infrastructure
  commit: stop setting rename limit
  bump rename limit defaults (again)
  merge: improve inexact rename limit warning
This commit is contained in:
Junio C Hamano 2011-03-19 23:23:56 -07:00
commit 0ce6a51b43
9 changed files with 49 additions and 10 deletions

View File

@ -75,9 +75,17 @@ option can be used to override --squash.
ifndef::git-pull[]
-q::
--quiet::
Operate quietly.
Operate quietly. Implies --no-progress.
-v::
--verbose::
Be verbose.
--progress::
--no-progress::
Turn progress on/off explicitly. If neither is specified,
progress is shown if standard error is connected to a terminal.
Note that not all merge strategies may support progress
reporting.
endif::git-pull[]

View File

@ -1285,7 +1285,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
get_commit_format(format.buf, &rev);
rev.always_show_header = 0;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 100;
rev.diffopt.break_opt = 0;
diff_setup_done(&rev.diffopt);

View File

@ -58,6 +58,7 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
static int show_progress = -1;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@ -200,6 +201,7 @@ static struct option builtin_merge_options[] = {
OPT__VERBOSITY(&verbosity),
OPT_BOOLEAN(0, "abort", &abort_current_merge,
"abort the current in-progress merge"),
OPT_SET_INT(0, "progress", &show_progress, "force progress reporting", 1),
OPT_END()
};
@ -660,6 +662,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
o.subtree_shift = "";
o.renormalize = option_renormalize;
o.show_rename_progress =
show_progress == -1 ? isatty(2) : show_progress;
for (x = 0; x < xopts_nr; x++)
if (parse_merge_opt(&o, xopts[x]))
@ -974,6 +978,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, builtin_merge_options,
builtin_merge_usage, 0);
if (verbosity < 0 && show_progress == -1)
show_progress = 0;
if (abort_current_merge) {
int nargc = 2;
const char *nargv[] = {"reset", "--merge", NULL};

2
diff.c
View File

@ -23,7 +23,7 @@
#endif
static int diff_detect_rename_default;
static int diff_rename_limit_default = 200;
static int diff_rename_limit_default = 400;
static int diff_suppress_blank_empty;
int diff_use_color_default = -1;
static const char *diff_word_regex_cfg;

3
diff.h
View File

@ -110,7 +110,8 @@ struct diff_options {
int pickaxe_opts;
int rename_score;
int rename_limit;
int warn_on_too_large_rename;
int needed_rename_limit;
int show_rename_progress;
int dirstat_percent;
int setup;
int abbrev;

View 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;
@ -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);

View File

@ -53,6 +53,8 @@ do
verbosity="$verbosity -v" ;;
--progress)
progress=--progress ;;
--no-progress)
progress=--no-progress ;;
-n|--no-stat|--no-summary)
diffstat=--no-stat ;;
--stat|--summary)
@ -293,8 +295,8 @@ true)
;;
*)
eval="git-merge $diffstat $no_commit $squash $no_ff $ff_only"
eval="$eval $log_arg $strategy_args $merge_args"
eval="$eval \"\$merge_name\" HEAD $merge_head $verbosity"
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
eval="$eval \"\$merge_name\" HEAD $merge_head"
;;
esac
eval "exec $eval"

View File

@ -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)
{
@ -418,14 +423,16 @@ static struct string_list *get_renames(struct merge_options *o,
opts.detect_rename = DIFF_DETECT_RENAME;
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
500;
1000;
opts.rename_score = o->rename_score;
opts.warn_on_too_large_rename = 1;
opts.show_rename_progress = o->show_rename_progress;
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;
@ -1649,6 +1656,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;
}

View File

@ -20,6 +20,8 @@ struct merge_options {
int diff_rename_limit;
int merge_rename_limit;
int rename_score;
int needed_rename_limit;
int show_rename_progress;
int call_depth;
struct strbuf obuf;
struct string_list current_file_set;