From: "Felipe Gonçalves Assis" <felipeg.assis@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, gitster@pobox.com,
sunshine@sunshineco.com,
"Felipe Gonçalves Assis" <felipegassis@gmail.com>
Subject: [PATCH v5 2/3] merge-recursive: option to disable renames
Date: Sat, 20 Feb 2016 23:34:31 -0300 [thread overview]
Message-ID: <1456022072-5342-3-git-send-email-felipegassis@gmail.com> (raw)
In-Reply-To: <1456022072-5342-1-git-send-email-felipegassis@gmail.com>
The recursive strategy turns on rename detection by default. Add a
strategy option to disable rename detection even for exact renames.
Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
---
Added tests.
For consistent naming, I renamed and slightly edited the test of whitespace
options:
t/t3032-merge-recursive-options.sh -> t/t3032-merge-recursive-space-options.sh
Documentation/merge-strategies.txt | 6 ++++++
merge-recursive.c | 7 +++++++
merge-recursive.h | 1 +
...ons.sh => t3032-merge-recursive-space-options.sh} | 2 +-
...ld.sh => t3034-merge-recursive-rename-options.sh} | 20 +++++++++++++++++++-
5 files changed, 34 insertions(+), 2 deletions(-)
rename t/{t3032-merge-recursive-options.sh => t3032-merge-recursive-space-options.sh} (99%)
rename t/{t3034-merge-recursive-rename-threshold.sh => t3034-merge-recursive-rename-options.sh} (83%)
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 7bbd19b..1a5e197 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -81,8 +81,14 @@ no-renormalize;;
Disables the `renormalize` option. This overrides the
`merge.renormalize` configuration variable.
+no-renames;;
+ Turn off rename detection.
+ See also linkgit:git-diff[1] `--no-renames`.
+
rename-threshold=<n>;;
Controls the similarity threshold used for rename detection.
+ Re-enables rename detection if disabled by a preceding
+ `no-renames`.
See also linkgit:git-diff[1] `-M`.
subtree[=<path>];;
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..6dd0a11 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -482,6 +482,9 @@ static struct string_list *get_renames(struct merge_options *o,
struct diff_options opts;
renames = xcalloc(1, sizeof(struct string_list));
+ if (!o->detect_rename)
+ return renames;
+
diff_setup(&opts);
DIFF_OPT_SET(&opts, RECURSIVE);
DIFF_OPT_CLR(&opts, RENAME_EMPTY);
@@ -2039,6 +2042,7 @@ void init_merge_options(struct merge_options *o)
o->diff_rename_limit = -1;
o->merge_rename_limit = -1;
o->renormalize = 0;
+ o->detect_rename = 1;
merge_recursive_config(o);
if (getenv("GIT_MERGE_VERBOSITY"))
o->verbosity =
@@ -2088,9 +2092,12 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o->renormalize = 1;
else if (!strcmp(s, "no-renormalize"))
o->renormalize = 0;
+ else if (!strcmp(s, "no-renames"))
+ o->detect_rename = 0;
else if (skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg != 0)
return -1;
+ o->detect_rename = 1;
}
else
return -1;
diff --git a/merge-recursive.h b/merge-recursive.h
index 9e090a3..52f0201 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -17,6 +17,7 @@ struct merge_options {
unsigned renormalize : 1;
long xdl_opts;
int verbosity;
+ int detect_rename;
int diff_rename_limit;
int merge_rename_limit;
int rename_score;
diff --git a/t/t3032-merge-recursive-options.sh b/t/t3032-merge-recursive-space-options.sh
similarity index 99%
rename from t/t3032-merge-recursive-options.sh
rename to t/t3032-merge-recursive-space-options.sh
index 4029c9c..b56180e 100755
--- a/t/t3032-merge-recursive-options.sh
+++ b/t/t3032-merge-recursive-space-options.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='merge-recursive options
+test_description='merge-recursive space options
* [master] Clarify
! [remote] Remove cruft
diff --git a/t/t3034-merge-recursive-rename-threshold.sh b/t/t3034-merge-recursive-rename-options.sh
similarity index 83%
rename from t/t3034-merge-recursive-rename-threshold.sh
rename to t/t3034-merge-recursive-rename-options.sh
index f0b3f44..2f10fa7 100755
--- a/t/t3034-merge-recursive-rename-threshold.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='merge-recursive rename threshold option
+test_description='merge-recursive rename options
Test rename detection by examining rename/delete conflicts.
@@ -137,10 +137,28 @@ test_expect_success 'rename threshold is truncated' '
check_find_renames_100
'
+test_expect_success 'disabled rename detection' '
+ git read-tree --reset -u HEAD &&
+ git merge-recursive --no-renames HEAD^ -- HEAD master &&
+ check_no_renames
+'
+
test_expect_success 'last wins in --rename-threshold=<m> --rename-threshold=<n>' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive --rename-threshold=25 --rename-threshold=75 HEAD^ -- HEAD master &&
check_find_renames_75
'
+test_expect_success 'last wins in --no-renames --rename-threshold=<n>' '
+ git read-tree --reset -u HEAD &&
+ test_must_fail git merge-recursive --no-renames --rename-threshold=25 HEAD^ -- HEAD master &&
+ check_find_renames_25
+'
+
+test_expect_success 'last wins in --rename-threshold=<n> --no-renames' '
+ git read-tree --reset -u HEAD &&
+ git merge-recursive --rename-threshold=25 --no-renames HEAD^ -- HEAD master &&
+ check_no_renames
+'
+
test_done
--
2.7.1.342.gf5bb636
next prev parent reply other threads:[~2016-02-21 2:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-21 2:34 [PATCH v5 0/3] merge-recursive: option to disable renames Felipe Gonçalves Assis
2016-02-21 2:34 ` [PATCH v5 1/3] merge-recursive: test rename threshold option Felipe Gonçalves Assis
2016-02-21 2:34 ` Felipe Gonçalves Assis [this message]
2016-02-21 2:34 ` [PATCH v5 3/3] merge-recursive: more consistent interface Felipe Gonçalves Assis
2016-02-21 7:40 ` [PATCH v5 0/3] merge-recursive: option to disable renames Junio C Hamano
2016-02-21 15:07 ` Felipe Gonçalves Assis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456022072-5342-3-git-send-email-felipegassis@gmail.com \
--to=felipeg.assis@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=felipegassis@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).