@matheusbsbs / matheus-bagliano / commits / 2a2ac92654
Fork 0

add merge.renamelimit config option

The point of rename limiting is to bound the amount of time we spend figuring out inexact renames. Currently we use a single value, diff.renamelimit, for all situations. However, it is probably the case that a user is willing to spend more time finding renames during a merge than they are while looking at git-log. This patch provides a way of setting those values separately (though for backwards compatibility, merge still falls back on the diff renamelimit). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Apr 30, 2008 at 13:23 UTC 2a2ac926547bc4fa91fcd1cb741dd5691ba9b974
3 files changed +88 -3
Documentation/merge-config.txt
+5
@@ -6,6 +6,11 @@ merge.log::
6 Whether to include summaries of merged commits in newly created
7 merge commit messages. False by default.
8
9 +merge.renameLimit::
10 + The number of files to consider when performing rename detection
11 + during a merge; if not specified, defaults to the value of
12 + diff.renameLimit.
13 +
14 merge.tool::
15 Controls which merge resolution program is used by
16 linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
builtin-merge-recursive.c
+10 -3
@@ -92,7 +92,8 @@ static struct path_list current_directory_set = {NULL, 0, 0, 1};
92
93 static int call_depth = 0;
94 static int verbosity = 2;
95 -static int rename_limit = -1;
95 +static int diff_rename_limit = -1;
96 +static int merge_rename_limit = -1;
97 static int buffer_output = 1;
98 static struct strbuf obuf = STRBUF_INIT;
99
@@ -361,7 +362,9 @@ static struct path_list *get_renames(struct tree *tree,
362 diff_setup(&opts);
363 DIFF_OPT_SET(&opts, RECURSIVE);
364 opts.detect_rename = DIFF_DETECT_RENAME;
364 - opts.rename_limit = rename_limit;
365 + opts.rename_limit = merge_rename_limit >= 0 ? merge_rename_limit :
366 + diff_rename_limit >= 0 ? diff_rename_limit :
367 + 100;
368 opts.output_format = DIFF_FORMAT_NO_OUTPUT;
369 if (diff_setup_done(&opts) < 0)
370 die("diff setup failed");
@@ -1343,7 +1346,11 @@ static int merge_config(const char *var, const char *value)
1346 return 0;
1347 }
1348 if (!strcasecmp(var, "diff.renamelimit")) {
1346 - rename_limit = git_config_int(var, value);
1349 + diff_rename_limit = git_config_int(var, value);
1350 + return 0;
1351 + }
1352 + if (!strcasecmp(var, "merge.renamelimit")) {
1353 + merge_rename_limit = git_config_int(var, value);
1354 return 0;
1355 }
1356 return git_default_config(var, value);
t/t6032-merge-large-rename.sh new
+73
@@ -0,0 +1,73 @@
1 +#!/bin/sh
2 +
3 +test_description='merging with large rename matrix'
4 +. ./test-lib.sh
5 +
6 +count() {
7 + i=1
8 + while test $i -le $1; do
9 + echo $i
10 + i=$(($i + 1))
11 + done
12 +}
13 +
14 +test_expect_success 'setup (initial)' '
15 + touch file &&
16 + git add . &&
17 + git commit -m initial &&
18 + git tag initial
19 +'
20 +
21 +make_text() {
22 + echo $1: $2
23 + for i in `count 20`; do
24 + echo $1: $i
25 + done
26 + echo $1: $3
27 +}
28 +
29 +test_rename() {
30 + test_expect_success "rename ($1, $2)" '
31 + n='$1'
32 + expect='$2'
33 + git checkout -f master &&
34 + git branch -D test$n || true &&
35 + git reset --hard initial &&
36 + for i in $(count $n); do
37 + make_text $i initial initial >$i
38 + done &&
39 + git add . &&
40 + git commit -m add=$n &&
41 + for i in $(count $n); do
42 + make_text $i changed initial >$i
43 + done &&
44 + git commit -a -m change=$n &&
45 + git checkout -b test$n HEAD^ &&
46 + for i in $(count $n); do
47 + git rm $i
48 + make_text $i initial changed >$i.moved
49 + done &&
50 + git add . &&
51 + git commit -m change+rename=$n &&
52 + case "$expect" in
53 + ok) git merge master ;;
54 + *) test_must_fail git merge master ;;
55 + esac
56 + '
57 +}
58 +
59 +test_rename 5 ok
60 +
61 +test_expect_success 'set diff.renamelimit to 4' '
62 + git config diff.renamelimit 4
63 +'
64 +test_rename 4 ok
65 +test_rename 5 fail
66 +
67 +test_expect_success 'set merge.renamelimit to 5' '
68 + git config merge.renamelimit 5
69 +'
70 +test_rename 5 ok
71 +test_rename 6 fail
72 +
73 +test_done