Skip to content

Commit 0ce6a51

Browse files
committed
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
2 parents edf9d71 + bebd2fd commit 0ce6a51

File tree

9 files changed

+49
-10
lines changed

9 files changed

+49
-10
lines changed

Documentation/merge-options.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ option can be used to override --squash.
7575
ifndef::git-pull[]
7676
-q::
7777
--quiet::
78-
Operate quietly.
78+
Operate quietly. Implies --no-progress.
7979

8080
-v::
8181
--verbose::
8282
Be verbose.
83+
84+
--progress::
85+
--no-progress::
86+
Turn progress on/off explicitly. If neither is specified,
87+
progress is shown if standard error is connected to a terminal.
88+
Note that not all merge strategies may support progress
89+
reporting.
90+
8391
endif::git-pull[]

builtin/commit.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
12851285
get_commit_format(format.buf, &rev);
12861286
rev.always_show_header = 0;
12871287
rev.diffopt.detect_rename = 1;
1288-
rev.diffopt.rename_limit = 100;
12891288
rev.diffopt.break_opt = 0;
12901289
diff_setup_done(&rev.diffopt);
12911290

builtin/merge.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static int option_renormalize;
5858
static int verbosity;
5959
static int allow_rerere_auto;
6060
static int abort_current_merge;
61+
static int show_progress = -1;
6162

6263
static struct strategy all_strategy[] = {
6364
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -200,6 +201,7 @@ static struct option builtin_merge_options[] = {
200201
OPT__VERBOSITY(&verbosity),
201202
OPT_BOOLEAN(0, "abort", &abort_current_merge,
202203
"abort the current in-progress merge"),
204+
OPT_SET_INT(0, "progress", &show_progress, "force progress reporting", 1),
203205
OPT_END()
204206
};
205207

@@ -660,6 +662,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
660662
o.subtree_shift = "";
661663

662664
o.renormalize = option_renormalize;
665+
o.show_rename_progress =
666+
show_progress == -1 ? isatty(2) : show_progress;
663667

664668
for (x = 0; x < xopts_nr; x++)
665669
if (parse_merge_opt(&o, xopts[x]))
@@ -974,6 +978,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
974978
argc = parse_options(argc, argv, prefix, builtin_merge_options,
975979
builtin_merge_usage, 0);
976980

981+
if (verbosity < 0 && show_progress == -1)
982+
show_progress = 0;
983+
977984
if (abort_current_merge) {
978985
int nargc = 2;
979986
const char *nargv[] = {"reset", "--merge", NULL};

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#endif
2424

2525
static int diff_detect_rename_default;
26-
static int diff_rename_limit_default = 200;
26+
static int diff_rename_limit_default = 400;
2727
static int diff_suppress_blank_empty;
2828
int diff_use_color_default = -1;
2929
static const char *diff_word_regex_cfg;

diff.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ struct diff_options {
110110
int pickaxe_opts;
111111
int rename_score;
112112
int rename_limit;
113-
int warn_on_too_large_rename;
113+
int needed_rename_limit;
114+
int show_rename_progress;
114115
int dirstat_percent;
115116
int setup;
116117
int abbrev;

diffcore-rename.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "diff.h"
66
#include "diffcore.h"
77
#include "hash.h"
8+
#include "progress.h"
89

910
/* Table of rename/copy destinations */
1011

@@ -449,6 +450,7 @@ void diffcore_rename(struct diff_options *options)
449450
struct diff_score *mx;
450451
int i, j, rename_count;
451452
int num_create, num_src, dst_cnt;
453+
struct progress *progress = NULL;
452454

453455
if (!minimum_score)
454456
minimum_score = DEFAULT_RENAME_SCORE;
@@ -518,15 +520,22 @@ void diffcore_rename(struct diff_options *options)
518520
* but handles the potential overflow case specially (and we
519521
* assume at least 32-bit integers)
520522
*/
523+
options->needed_rename_limit = 0;
521524
if (rename_limit <= 0 || rename_limit > 32767)
522525
rename_limit = 32767;
523526
if ((num_create > rename_limit && num_src > rename_limit) ||
524527
(num_create * num_src > rename_limit * rename_limit)) {
525-
if (options->warn_on_too_large_rename)
526-
warning("too many files (created: %d deleted: %d), skipping inexact rename detection", num_create, num_src);
528+
options->needed_rename_limit =
529+
num_src > num_create ? num_src : num_create;
527530
goto cleanup;
528531
}
529532

533+
if (options->show_rename_progress) {
534+
progress = start_progress_delay(
535+
"Performing inexact rename detection",
536+
rename_dst_nr * rename_src_nr, 50, 1);
537+
}
538+
530539
mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
531540
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
532541
struct diff_filespec *two = rename_dst[i].two;
@@ -556,7 +565,9 @@ void diffcore_rename(struct diff_options *options)
556565
diff_free_filespec_blob(two);
557566
}
558567
dst_cnt++;
568+
display_progress(progress, (i+1)*rename_src_nr);
559569
}
570+
stop_progress(&progress);
560571

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

git-pull.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ do
5353
verbosity="$verbosity -v" ;;
5454
--progress)
5555
progress=--progress ;;
56+
--no-progress)
57+
progress=--no-progress ;;
5658
-n|--no-stat|--no-summary)
5759
diffstat=--no-stat ;;
5860
--stat|--summary)
@@ -293,8 +295,8 @@ true)
293295
;;
294296
*)
295297
eval="git-merge $diffstat $no_commit $squash $no_ff $ff_only"
296-
eval="$eval $log_arg $strategy_args $merge_args"
297-
eval="$eval \"\$merge_name\" HEAD $merge_head $verbosity"
298+
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
299+
eval="$eval \"\$merge_name\" HEAD $merge_head"
298300
;;
299301
esac
300302
eval "exec $eval"

merge-recursive.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include "dir.h"
2323
#include "submodule.h"
2424

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+
2530
static struct tree *shift_tree_object(struct tree *one, struct tree *two,
2631
const char *subtree_shift)
2732
{
@@ -418,14 +423,16 @@ static struct string_list *get_renames(struct merge_options *o,
418423
opts.detect_rename = DIFF_DETECT_RENAME;
419424
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
420425
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
421-
500;
426+
1000;
422427
opts.rename_score = o->rename_score;
423-
opts.warn_on_too_large_rename = 1;
428+
opts.show_rename_progress = o->show_rename_progress;
424429
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
425430
if (diff_setup_done(&opts) < 0)
426431
die("diff setup failed");
427432
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
428433
diffcore_std(&opts);
434+
if (opts.needed_rename_limit > o->needed_rename_limit)
435+
o->needed_rename_limit = opts.needed_rename_limit;
429436
for (i = 0; i < diff_queued_diff.nr; ++i) {
430437
struct string_list_item *item;
431438
struct rename *re;
@@ -1649,6 +1656,8 @@ int merge_recursive(struct merge_options *o,
16491656
commit_list_insert(h2, &(*result)->parents->next);
16501657
}
16511658
flush_output(o);
1659+
if (o->needed_rename_limit)
1660+
warning(rename_limit_advice, o->needed_rename_limit);
16521661
return clean;
16531662
}
16541663

merge-recursive.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct merge_options {
2020
int diff_rename_limit;
2121
int merge_rename_limit;
2222
int rename_score;
23+
int needed_rename_limit;
24+
int show_rename_progress;
2325
int call_depth;
2426
struct strbuf obuf;
2527
struct string_list current_file_set;

0 commit comments

Comments
 (0)