Re: [PATCH 1/5] Documentation/diff-config: fix description of diff.renames

2016-02-25 Thread Felipe Gonçalves Assis
Matthieu Moy  imag.fr> writes:

>  diff.renames::
> - Tells Git to detect renames.  If set to any boolean value, it
> - will enable basic rename detection.  If set to "copies" or
> - "copy", it will detect copies, as well.
> + Whether and how Git detects renames.  If set to "false",
> + rename detection is disabled. If set to "true", basic rename
> + detection is enable.  If set to "copies" or "copy", Git will
> + detect copies, as well.  Defaults to false.

Just a minor typo: s/enable/enabled/
Also, there is only one space between the second and third sentences.

Just in case you haven't already fixed that.

Regards,
Felipe

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/3] Tests for merge-recursive rename-options

2016-02-24 Thread Felipe Gonçalves Assis
On 23 February 2016 at 22:41, Felipe Gonçalves Assis
 wrote:
> Just a quick update incorporating Eric's latest comments.
>
> Still based on
> c443d39 (merge-recursive: find-renames resets threshold, 2016-02-21).
>

One thing I just noticed is that the description of c443d39 still has
a line saying "Add corresponding test.", even though it does not
include any tests. Could you remove that?

Thanks,
Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] t3034: test deprecated interface

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

--find-renames= and --rename-threshold= should be aliases.

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 46 +++
 1 file changed, 46 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 2479910..b9c4028 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -263,4 +263,50 @@ test_expect_success '--find-renames rejects non-numbers' '
git diff --quiet --cached
 '
 
+test_expect_success 'rename-threshold= is a synonym for find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=$th0 $tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --no-renames --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --rename-threshold=$th0 
$tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --rename-threshold= --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --rename-threshold=$th0 --no-renames $tail &&
+   check_no_renames
+'
+
+test_expect_success '--rename-threshold= rejects negative argument' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=-25 \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success '--rename-threshold= rejects non-numbers' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=0xf \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success 'last wins in --rename-threshold= --find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --rename-threshold=$th0 --find-renames=$th2 $tail &&
+   check_threshold_2
+'
+
+test_expect_success 'last wins in --find-renames= --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --find-renames=$th2 --rename-threshold=$th0 $tail &&
+   check_threshold_0
+'
+
 test_done
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] t3034: test option to disable renames

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 28 
 1 file changed, 28 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 51c2f87..2479910 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -83,6 +83,14 @@ check_exact_renames () {
rename_detected 3
 }
 
+check_no_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_undetected 3
+}
+
 test_expect_success 'setup repo' '
cat <<-\EOF >3-old &&
33a
@@ -195,6 +203,12 @@ test_expect_success 'rename threshold is truncated' '
check_exact_renames
 '
 
+test_expect_success 'disabled rename detection' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'last wins in --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive \
@@ -209,6 +223,18 @@ test_expect_success '--find-renames resets threshold' '
$check_50
 '
 
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --find-renames $tail &&
+   $check_50
+'
+
+test_expect_success 'last wins in --find-renames --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --find-renames --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'assumption for further tests: trivial merge succeeds' '
git read-tree --reset -u HEAD &&
git merge-recursive HEAD -- HEAD HEAD &&
@@ -218,6 +244,8 @@ test_expect_success 'assumption for further tests: trivial 
merge succeeds' '
git merge-recursive --find-renames=$th2 HEAD -- HEAD HEAD &&
git diff --quiet --cached &&
git merge-recursive --find-renames=100% HEAD -- HEAD HEAD &&
+   git diff --quiet --cached &&
+   git merge-recursive --no-renames HEAD -- HEAD HEAD &&
git diff --quiet --cached
 '
 
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/3] Tests for merge-recursive rename-options

2016-02-23 Thread Felipe Gonçalves Assis
Just a quick update incorporating Eric's latest comments.

Still based on
c443d39 (merge-recursive: find-renames resets threshold, 2016-02-21).

Felipe Gonçalves Assis (3):
  t3034: add rename threshold tests
  t3034: test option to disable renames
  t3034: test deprecated interface

 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 312 +
 2 files changed, 313 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] t3034: add rename threshold tests

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

10ae752 (merge-recursive: option to specify rename threshold,
2010-09-27) introduced this feature but did not include any tests.

The tests use the new option --find-renames, which replaces the then
introduced and now deprecated option --rename-threshold.

Also update name and description of t3032 for consistency:
"merge-recursive options" -> "merge-recursive space options"

Signed-off-by: Felipe Gonçalves Assis 
---
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 238 +
 2 files changed, 239 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

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-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
new file mode 100755
index 000..51c2f87
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -0,0 +1,238 @@
+#!/bin/sh
+
+test_description='merge-recursive rename options
+
+Test rename detection by examining rename/delete conflicts.
+
+* (HEAD -> rename) rename
+| * (master) delete
+|/
+* base
+
+git diff --name-status base master
+D  0-old
+D  1-old
+D  2-old
+D  3-old
+
+git diff --name-status -M01 base rename
+R0250-old   0-new
+R0501-old   1-new
+R0752-old   2-new
+R1003-old   3-new
+
+Actual similarity indices are parsed from diff output. We rely on the fact that
+they are rounded down (see, e.g., Documentation/diff-generate-patch.txt, which
+mentions this in a different context).
+'
+
+. ./test-lib.sh
+
+get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new >expected-stages-undetected-$1 &&
+   sed "s/ 0   / 2 /" expected-stages-detected-$1 &&
+   git read-tree -u --reset HEAD
+}
+
+rename_detected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+}
+
+rename_undetected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+}
+
+check_common () {
+   git ls-files --stage >stages-actual &&
+   test_line_count = 4 stages-actual
+}
+
+check_threshold_0 () {
+   check_common &&
+   rename_detected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_1 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_2 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_exact_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_detected 3
+}
+
+test_expect_success 'setup repo' '
+   cat <<-\EOF >3-old &&
+   33a
+   33b
+   33c
+   33d
+   EOF
+   sed s/33/22/ <3-old >2-old &&
+   sed s/33/11/ <3-old >1-old &&
+   sed s/33/00/ <3-old >0-old &&
+   git add [0-3]-old &&
+   git commit -m base &&
+   git rm [0-3]-old &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp 3-old 3-new &&
+   sed 1,1s/./x/ <2-old >2-new &&
+   sed 1,2s/./x/ <1-old >1-new &&
+   sed 1,3s/./x/ <0-old >0-new &&
+   git add [0-3]-new &&
+   git rm [0-3]-old &&
+   git commit -m rename &&
+   get_expected_stages 0 &&
+   get_expected_stages 1 &&
+   get_expected_stages 2 &&
+   get_expected_stages 3 &&
+   check_50="false" &&
+   tail="HEAD^ -- HEAD master"
+'
+
+test_expect_success 'setup thresholds' '
+   git diff --name-status -M01 HEAD^ HEAD >diff-output &&
+   test_de

Re: [PATCH 1/3] t3034: add rename threshold tests

2016-02-23 Thread Felipe Gonçalves Assis
On 23 February 2016 at 21:50, Eric Sunshine  wrote:
> On Tue, Feb 23, 2016 at 6:48 PM, Felipe Gonçalves Assis
>  wrote:
>> 10ae752 (merge-recursive: option to specify rename threshold,
>> 2010-09-27) introduced this feature but did not include any tests.
>>
>> The tests use the new option --find-renames, which replaces the then
>> introduced and now deprecated option --rename-threshold.
>>
>> Also update name and description of t3032 for consistency:
>> "merge-recursive options" -> "merge-recursive space options"
>
> A few superficial comments below...
>
>> +   cat <<-\EOF >3-old &&
>> +   33a
>> +   33b
>> +   33c
>> +   33d
>> +   EOF
>> +   sed s/33/22/ <3-old >2-old &&
>> +   sed s/33/11/ <3-old >1-old &&
>> +   sed s/33/00/ <3-old >0-old &&
>> +   git add [0-3]-old &&
>> +   git commit -m base &&
>> +   git rm [0-3]-old &&
>> +   git commit -m delete &&
>> +   git checkout -b rename HEAD^ &&
>> +   cp 3-old 3-new &&
>> +   sed 1,1s/./x/ <2-old >2-new &&
>> +   sed 1,2s/./x/ <1-old >1-new &&
>> +   sed 1,3s/./x/ <0-old >0-new &&
>> +   git add [0-3]-new &&
>> +   git rm [0-3]-old &&
>> +   git commit -m rename &&
>> +   get_expected_stages 0 &&
>> +   get_expected_stages 1 &&
>> +   get_expected_stages 2 &&
>> +   get_expected_stages 3 &&
>> +   check_50="false" &&
>
> Why isn't this assignment done in setup 2/2 where all the other
> assignments to 'check_50' are done?
>

Oh, it might be a minor thing, but I would like to make tests using
check_50 fail if setup 2/2 is skipped, instead of succeeding without
any actual checks.

>> +   th0=$(sed -n "s/R\(...\)0-old   0-new/\1/p" > +   th1=$(sed -n "s/R\(...\)1-old   1-new/\1/p" > +   th2=$(sed -n "s/R\(...\)2-old   2-new/\1/p" > +   th3=$(sed -n "s/R\(...\)3-old   3-new/\1/p" > +   test "$th0" -lt "$th1" &&
>> +   test "$th1" -lt "$th2" &&
>> +   test "$th2" -lt "$th3" &&
>> +   test "$th3" = 100 &&
>
> It's very slightly odd to see '=' rather than '-eq' among all these
> other algebraic operators ('-lt', '-le'), but not so odd that I'd
> mention it (unless I just did), and not necessarily worth changing.
>

Here I favoured the stricter test. If the string is not exactly "100",
then a lot should be reviewed.

Once more, thanks for the review. Your other comments should be
included in the next version of the patches.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] t3034: test deprecated interface

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

--find-renames= and --rename-threshold= should be aliases.

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 46 +++
 1 file changed, 46 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index c07a4cb..96d8767 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -260,4 +260,50 @@ test_expect_success '--find-renames rejects non-numbers' '
git diff --quiet --cached
 '
 
+test_expect_success 'rename-threshold= is a synonym for find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=$th0 $tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --no-renames --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --rename-threshold=$th0 
$tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --rename-threshold= --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --rename-threshold=$th0 --no-renames $tail &&
+   check_no_renames
+'
+
+test_expect_success '--rename-threshold= rejects negative argument' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=-25 \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success '--rename-threshold= rejects non-numbers' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=0xf \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success 'last wins in --rename-threshold= --find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --rename-threshold=$th0 --find-renames=$th2 $tail &&
+   check_threshold_2
+'
+
+test_expect_success 'last wins in --find-renames= --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --find-renames=$th2 --rename-threshold=$th0 $tail &&
+   check_threshold_0
+'
+
 test_done
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] t3034: add rename threshold tests

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

10ae752 (merge-recursive: option to specify rename threshold,
2010-09-27) introduced this feature but did not include any tests.

The tests use the new option --find-renames, which replaces the then
introduced and now deprecated option --rename-threshold.

Also update name and description of t3032 for consistency:
"merge-recursive options" -> "merge-recursive space options"

Signed-off-by: Felipe Gonçalves Assis 
---
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 235 +
 2 files changed, 236 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

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-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
new file mode 100755
index 000..fbec68c
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -0,0 +1,235 @@
+#!/bin/sh
+
+test_description='merge-recursive rename options
+
+Test rename detection by examining rename/delete conflicts.
+
+* (HEAD -> rename) rename
+| * (master) delete
+|/
+* base
+
+git diff --name-status base master
+D  0-old
+D  1-old
+D  2-old
+D  3-old
+
+git diff --name-status -M01 base rename
+R0250-old   0-new
+R0501-old   1-new
+R0752-old   2-new
+R1003-old   3-new
+
+Actual similarity indices are parsed from diff output. We rely on the fact that
+they are rounded down (see, e.g., Documentation/diff-generate-patch.txt, which
+mentions this in a different context).
+'
+
+. ./test-lib.sh
+
+get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new >expected-stages-undetected-$1 &&
+   sed "s/ 0   / 2 /" expected-stages-detected-$1 &&
+   git read-tree -u --reset HEAD
+}
+
+rename_detected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+}
+
+rename_undetected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+}
+
+check_common () {
+   git ls-files --stage >stages-actual &&
+   test_line_count = 4 stages-actual
+}
+
+check_threshold_0 () {
+   check_common &&
+   rename_detected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_1 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_2 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_exact_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_detected 3
+}
+
+test_expect_success 'setup 1/2: basic setup' '
+   cat <<-\EOF >3-old &&
+   33a
+   33b
+   33c
+   33d
+   EOF
+   sed s/33/22/ <3-old >2-old &&
+   sed s/33/11/ <3-old >1-old &&
+   sed s/33/00/ <3-old >0-old &&
+   git add [0-3]-old &&
+   git commit -m base &&
+   git rm [0-3]-old &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp 3-old 3-new &&
+   sed 1,1s/./x/ <2-old >2-new &&
+   sed 1,2s/./x/ <1-old >1-new &&
+   sed 1,3s/./x/ <0-old >0-new &&
+   git add [0-3]-new &&
+   git rm [0-3]-old &&
+   git commit -m rename &&
+   get_expected_stages 0 &&
+   get_expected_stages 1 &&
+   get_expected_stages 2 &&
+   get_expected_stages 3 &&
+   check_50="false" &&
+   tail="HEAD^ -- HEAD master"
+'
+
+test_expect_success 'setup 2/2: threshold array' '
+   git diff --name-status -M01 HEAD^ HEAD >diff-output &&

[PATCH 2/3] t3034: test option to disable renames

2016-02-23 Thread Felipe Gonçalves Assis
From: Felipe Gonçalves Assis 

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 28 
 1 file changed, 28 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index fbec68c..c07a4cb 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -83,6 +83,14 @@ check_exact_renames () {
rename_detected 3
 }
 
+check_no_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_undetected 3
+}
+
 test_expect_success 'setup 1/2: basic setup' '
cat <<-\EOF >3-old &&
33a
@@ -192,6 +200,12 @@ test_expect_success 'rename threshold is truncated' '
check_exact_renames
 '
 
+test_expect_success 'disabled rename detection' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'last wins in --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive \
@@ -206,6 +220,18 @@ test_expect_success '--find-renames resets threshold' '
$check_50
 '
 
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --find-renames $tail &&
+   $check_50
+'
+
+test_expect_success 'last wins in --find-renames --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --find-renames --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'assumption for further tests: trivial merge succeeds' '
git read-tree --reset -u HEAD &&
git merge-recursive HEAD -- HEAD HEAD &&
@@ -215,6 +241,8 @@ test_expect_success 'assumption for further tests: trivial 
merge succeeds' '
git merge-recursive --find-renames=$th2 HEAD -- HEAD HEAD &&
git diff --quiet --cached &&
git merge-recursive --find-renames=100% HEAD -- HEAD HEAD &&
+   git diff --quiet --cached &&
+   git merge-recursive --no-renames HEAD -- HEAD HEAD &&
git diff --quiet --cached
 '
 
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] Tests for merge-recursive rename options

2016-02-23 Thread Felipe Gonçalves Assis
Get rid of blatant bash-isms in favour of simple and portable constructions.

Felipe Gonçalves Assis (3):
  t3034: add rename threshold tests
  t3034: test option to disable renames
  t3034: test deprecated interface

 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 309 +
 2 files changed, 310 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] t3034: test deprecated interface

2016-02-22 Thread Felipe Gonçalves Assis
--find-renames= and --rename-threshold= should be aliases.

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 46 +++
 1 file changed, 46 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 03ce77c..59599ec 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -260,4 +260,50 @@ test_expect_success '--find-renames rejects non-numbers' '
git diff --quiet --cached
 '
 
+test_expect_success 'rename-threshold= is a synonym for find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=${th[0]} $tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --no-renames --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames 
--rename-threshold=${th[0]} $tail &&
+   check_threshold_0
+'
+
+test_expect_success 'last wins in --rename-threshold= --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --rename-threshold=${th[0]} --no-renames $tail &&
+   check_no_renames
+'
+
+test_expect_success '--rename-threshold= rejects negative argument' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=-${th[0]} \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success '--rename-threshold= rejects non-numbers' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=0xf \
+   HEAD -- HEAD HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success 'last wins in --rename-threshold= --find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --rename-threshold=${th[0]} --find-renames=${th[2]} $tail &&
+   check_threshold_2
+'
+
+test_expect_success 'last wins in --find-renames= --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive \
+   --find-renames=${th[2]} --rename-threshold=${th[0]} $tail &&
+   check_threshold_0
+'
+
 test_done
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] t3034: test option to disable renames

2016-02-22 Thread Felipe Gonçalves Assis
Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 28 
 1 file changed, 28 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 66fee8a..03ce77c 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -83,6 +83,14 @@ check_exact_renames () {
rename_detected 3
 }
 
+check_no_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_undetected 3
+}
+
 test_expect_success 'setup 1/2: basic setup' '
cat <<-\EOF >3-old &&
33a
@@ -192,6 +200,12 @@ test_expect_success 'rename threshold is truncated' '
check_exact_renames
 '
 
+test_expect_success 'disabled rename detection' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'last wins in --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive \
@@ -206,6 +220,18 @@ test_expect_success '--find-renames resets threshold' '
$check_50
 '
 
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --find-renames $tail &&
+   $check_50
+'
+
+test_expect_success 'last wins in --find-renames --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --find-renames --no-renames $tail &&
+   check_no_renames
+'
+
 test_expect_success 'assumption for further tests: trivial merge succeeds' '
git read-tree --reset -u HEAD &&
git merge-recursive HEAD -- HEAD HEAD &&
@@ -215,6 +241,8 @@ test_expect_success 'assumption for further tests: trivial 
merge succeeds' '
git merge-recursive --find-renames=${th[2]} HEAD -- HEAD HEAD &&
git diff --quiet --cached &&
git merge-recursive --find-renames=100% HEAD -- HEAD HEAD &&
+   git diff --quiet --cached &&
+   git merge-recursive --no-renames HEAD -- HEAD HEAD &&
git diff --quiet --cached
 '
 
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] t3034: add rename threshold tests

2016-02-22 Thread Felipe Gonçalves Assis
10ae752 (merge-recursive: option to specify rename threshold,
2010-09-27) introduced this feature but did not include any tests.

The tests use the new option --find-renames, which replaces the then
introduced and now deprecated option --rename-threshold.

Also update name and description of t3032 for consistency:
"merge-recursive options" -> "merge-recursive space options"

Signed-off-by: Felipe Gonçalves Assis 
---
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 235 +
 2 files changed, 236 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

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-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
new file mode 100755
index 000..66fee8a
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -0,0 +1,235 @@
+#!/bin/sh
+
+test_description='merge-recursive rename options
+
+Test rename detection by examining rename/delete conflicts.
+
+* (HEAD -> rename) rename
+| * (master) delete
+|/
+* base
+
+git diff --name-status base master
+D  0-old
+D  1-old
+D  2-old
+D  3-old
+
+git diff --name-status -M01 base rename
+R0250-old   0-new
+R0501-old   1-new
+R0752-old   2-new
+R1003-old   3-new
+
+Actual similarity indices are parsed from diff output. We rely on the fact that
+they are rounded down (see, e.g., Documentation/diff-generate-patch.txt, which
+mentions this in a different context).
+'
+
+. ./test-lib.sh
+
+get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new >expected-stages-undetected-$1 &&
+   sed "s/ 0   / 2 /" expected-stages-detected-$1 &&
+   git read-tree -u --reset HEAD
+}
+
+rename_detected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+}
+
+rename_undetected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+}
+
+check_common () {
+   git ls-files --stage >stages-actual &&
+   test_line_count = 4 stages-actual
+}
+
+check_threshold_0 () {
+   check_common &&
+   rename_detected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_1 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_detected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_threshold_2 () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_detected 2 &&
+   rename_detected 3
+}
+
+check_exact_renames () {
+   check_common &&
+   rename_undetected 0 &&
+   rename_undetected 1 &&
+   rename_undetected 2 &&
+   rename_detected 3
+}
+
+test_expect_success 'setup 1/2: basic setup' '
+   cat <<-\EOF >3-old &&
+   33a
+   33b
+   33c
+   33d
+   EOF
+   sed s/33/22/ <3-old >2-old &&
+   sed s/33/11/ <3-old >1-old &&
+   sed s/33/00/ <3-old >0-old &&
+   git add [0-3]-old &&
+   git commit -m base &&
+   git rm [0-3]-old &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp 3-old 3-new &&
+   sed 1,1s/./x/ <2-old >2-new &&
+   sed 1,2s/./x/ <1-old >1-new &&
+   sed 1,3s/./x/ <0-old >0-new &&
+   git add [0-3]-new &&
+   git rm [0-3]-old &&
+   git commit -m rename &&
+   get_expected_stages 0 &&
+   get_expected_stages 1 &&
+   get_expected_stages 2 &&
+   get_expected_stages 3 &&
+   check_50="false" &&
+   tail="HEAD^ -- HEAD master"
+'
+
+test_expect_success 'setup 2/2: threshold array' '
+   git diff --name-status -M01 HEAD^ HEAD >diff-output &&
+   test_debug "

[PATCH 0/3] Tests for merge-recursive rename options

2016-02-22 Thread Felipe Gonçalves Assis
Based on c443d39 (merge-recursive: find-renames resets threshold, 2016-02-21).

This patch involves only the tests for the features introduced in
fa/merge-recursive-no-rename, for better review.

The tests were rewritten so that the similarity indices are parsed instead of
assumed.

Felipe Gonçalves Assis (3):
  t3034: add rename threshold tests
  t3034: test option to disable renames
  t3034: test deprecated interface

 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 309 +
 2 files changed, 310 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/5] Tests and fixes for merge-recursive rename options

2016-02-22 Thread Felipe Gonçalves Assis
On 22 February 2016 at 19:29, Junio C Hamano  wrote:
> Felipe Gonçalves Assis  writes:
>
>>> As I said, I am reluctant to take the 25%/50%/75% tests in their
>>> current form.  Let me take the first one and a half of the last one
>>> (i.e. excluding the test) for now.
>>>
>>> Thanks.
>>
>> Ok, should I post a new version of the patch without the tests while I
>> rework them or does that mean that you have already filtered them out
>> locally?
>
> I already have and queued them tentatively as
>
> c443d39 merge-recursive: find-renames resets threshold
> 83837ec merge-strategies.txt: fix typo
>
> but they haven't been merged to 'next', so it is up to you whether
> you rebuild the remainder on top of c443d39 or redo these 5 patches
> altogether (just tell me to drop these two if you go the latter
> route).
>

My original patch started with exactly those commits and then added
the tests, so it is fine for me.

The motivation for the reorganisation was bundling the relevant test
with the fix, but then it might be better to publish the fix soon,
right?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/5] Tests and fixes for merge-recursive rename options

2016-02-22 Thread Felipe Gonçalves Assis
On 22 February 2016 at 18:00, Junio C Hamano  wrote:
> "Felipe Gonçalves Assis"   writes:
>
>> This is a reorganisation of the previous series, bundling the test for the 
>> fix
>> along with the commit itself, as suggested by Eric. It also includes many 
>> fixes
>> and improvements pointed out by the same reviewer, whom I thank.
>>
>> The typo fix is the same as before.
>>
>> In "add rename threshold tests", I include tests involving --find-renames,
>> except for one that depends on the fix.
>>
>> "test option to disable renames" adds tests involving --rename-threshold.
>>
>> "test deprecated interface" tests the aliasing --rename-threshold.
>>
>> In "find-renames resets threshold", the specific test for the feature was
>> bundled along.
>>
>> To Junio: Please pay special attention to the test of threshold truncation.
>> Given that it seems to be an undocumented feature, I am not sure whether it
>> should be included or not.
>>
>> Felipe Gonçalves Assis (5):
>>   merge-strategies.txt: fix typo
>>   t3034: add rename threshold tests
>>   t3034: test option to disable renames
>>   t3034: test deprecated interface
>>   merge-recursive: find-renames resets threshold
>
> As I said, I am reluctant to take the 25%/50%/75% tests in their
> current form.  Let me take the first one and a half of the last one
> (i.e. excluding the test) for now.
>
> Thanks.

Ok, should I post a new version of the patch without the tests while I
rework them or does that mean that you have already filtered them out
locally?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/5] merge-strategies.txt: fix typo

2016-02-21 Thread Felipe Gonçalves Assis
Signed-off-by: Felipe Gonçalves Assis 
---
 Documentation/merge-strategies.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index ff359b6..2eb92b9 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -86,8 +86,8 @@ no-renames;;
See also linkgit:git-diff[1] `--no-renames`.
 
 find-renames[=];;
-   Turn on rename detection, optionally setting the the similarity
-   threshold. This is the default.
+   Turn on rename detection, optionally setting the similarity
+   threshold.  This is the default.
See also linkgit:git-diff[1] `--find-renames`.
 
 rename-threshold=;;
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/5] t3034: add rename threshold tests

2016-02-21 Thread Felipe Gonçalves Assis
10ae752 (merge-recursive: option to specify rename threshold,
2010-09-27) introduced this feature but did not include any tests.

The tests use the new option --find-renames, which replaces the then
introduced and now deprecated option --rename-threshold.

Also update name and description of t3032 for consistency:
"merge-recursive options" -> "merge-recursive space options"

Signed-off-by: Felipe Gonçalves Assis 
---

Now this already introduces the final names and descriptions for the tests.

The test for threshold truncation was kept for now. Please confirm whether it is
desirable.

New tests were added at the end to check that invalid arguments to find-renames=
such as negative and non-numbers error out.

 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 159 +
 2 files changed, 160 insertions(+), 1 deletion(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

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-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
new file mode 100755
index 000..7ae7f83
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+
+test_description='merge-recursive rename options
+
+Test rename detection by examining rename/delete conflicts.
+
+Similarity index:
+R100 a-old a-new
+R075 b-old b-new
+R050 c-old c-new
+R025 d-old d-new
+'
+
+. ./test-lib.sh
+
+get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new >expected-stages-undetected-$1 &&
+   sed "s/ 0   / 2 /" expected-stages-detected-$1 &&
+   git read-tree -u --reset HEAD
+}
+
+rename_detected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+}
+
+rename_undetected () {
+   git ls-files --stage $1-old $1-new >stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+}
+
+check_common () {
+   git ls-files --stage >stages-actual &&
+   test_line_count = 4 stages-actual
+}
+
+check_find_renames_25 () {
+   check_common &&
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_detected d
+}
+
+check_find_renames_50 () {
+   check_common &&
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_undetected d
+}
+
+check_find_renames_75 () {
+   check_common &&
+   rename_detected a &&
+   rename_detected b &&
+   rename_undetected c &&
+   rename_undetected d
+}
+
+check_find_renames_100 () {
+   check_common &&
+   rename_detected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+}
+
+test_expect_success setup '
+   cat <<-\EOF >a-old &&
+   aa1
+   aa2
+   aa3
+   aa4
+   EOF
+   sed s/aa/bb/ b-old &&
+   sed s/aa/cc/ c-old &&
+   sed s/aa/dd/ d-old &&
+   git add [a-d]-old &&
+   git commit -m base &&
+   git rm [a-d]-old &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp a-old a-new &&
+   sed 1,1s/./x/ b-new &&
+   sed 1,2s/./x/ c-new &&
+   sed 1,3s/./x/ d-new &&
+   git add [a-d]-new &&
+   git rm [a-d]-old &&
+   git commit -m rename &&
+   get_expected_stages a &&
+   get_expected_stages b &&
+   get_expected_stages c &&
+   get_expected_stages d
+'
+
+test_expect_success 'default similarity threshold is 50%' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'low rename threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames=25 HEAD^ -- HEAD 
master &&
+   check_find_

[PATCH v2 3/5] t3034: test option to disable renames

2016-02-21 Thread Felipe Gonçalves Assis
Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 28 
 1 file changed, 28 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 7ae7f83..a459236 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -68,6 +68,14 @@ check_find_renames_100 () {
rename_undetected d
 }
 
+check_no_renames () {
+   check_common &&
+   rename_undetected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+}
+
 test_expect_success setup '
cat <<-\EOF >a-old &&
aa1
@@ -126,12 +134,30 @@ 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 --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive --find-renames=25 --find-renames=75 
HEAD^ -- HEAD master &&
check_find_renames_75
 '
 
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --find-renames HEAD^ -- 
HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'last wins in --find-renames --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --find-renames --no-renames HEAD^ -- HEAD master &&
+   check_no_renames
+'
+
 test_expect_success 'assumption for further tests: trivial merge succeeds' '
git read-tree --reset -u HEAD &&
git merge-recursive HEAD -- HEAD HEAD &&
@@ -141,6 +167,8 @@ test_expect_success 'assumption for further tests: trivial 
merge succeeds' '
git merge-recursive --find-renames=75 HEAD -- HEAD HEAD &&
git diff --quiet --cached &&
git merge-recursive --find-renames=100% HEAD -- HEAD HEAD &&
+   git diff --quiet --cached &&
+   git merge-recursive --no-renames HEAD -- HEAD HEAD &&
git diff --quiet --cached
 '
 
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/5] Tests and fixes for merge-recursive rename options

2016-02-21 Thread Felipe Gonçalves Assis
This is a reorganisation of the previous series, bundling the test for the fix
along with the commit itself, as suggested by Eric. It also includes many fixes
and improvements pointed out by the same reviewer, whom I thank.

The typo fix is the same as before.

In "add rename threshold tests", I include tests involving --find-renames,
except for one that depends on the fix.

"test option to disable renames" adds tests involving --rename-threshold.

"test deprecated interface" tests the aliasing --rename-threshold.

In "find-renames resets threshold", the specific test for the feature was
bundled along.

To Junio: Please pay special attention to the test of threshold truncation.
Given that it seems to be an undocumented feature, I am not sure whether it
should be included or not.

Felipe Gonçalves Assis (5):
  merge-strategies.txt: fix typo
  t3034: add rename threshold tests
  t3034: test option to disable renames
  t3034: test deprecated interface
  merge-recursive: find-renames resets threshold

 Documentation/merge-strategies.txt |   4 +-
 merge-recursive.c  |   4 +-
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 235 +
 4 files changed, 241 insertions(+), 4 deletions(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/5] t3034: test deprecated interface

2016-02-21 Thread Felipe Gonçalves Assis
--find-renames= and --rename-threshold= should be aliases.

Signed-off-by: Felipe Gonçalves Assis 
---

Now includes tests with invalid arguments to --rename-threshold=

 t/t3034-merge-recursive-rename-options.sh | 42 +++
 1 file changed, 42 insertions(+)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index a459236..d4f9742 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -184,4 +184,46 @@ test_expect_success '--find-renames rejects non-numbers' '
git diff --quiet --cached
 '
 
+test_expect_success 'rename-threshold= is a synonym for find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   check_find_renames_25
+'
+
+test_expect_success 'last wins in --no-renames --rename-threshold=' '
+   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= --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --rename-threshold=25 --no-renames HEAD^ -- HEAD 
master &&
+   check_no_renames
+'
+
+test_expect_success '--rename-threshold= rejects negative argument' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=-25 HEAD -- HEAD 
HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success '--rename-threshold= rejects non-numbers' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=0xf HEAD -- HEAD 
HEAD &&
+   git diff --quiet --cached
+'
+
+test_expect_success 'last wins in --rename-threshold= --find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 
--find-renames=75 HEAD^ -- HEAD master &&
+   check_find_renames_75
+'
+
+test_expect_success 'last wins in --find-renames= --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames=75 
--rename-threshold=25 HEAD^ -- HEAD master &&
+   check_find_renames_25
+'
+
 test_done
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/5] merge-recursive: find-renames resets threshold

2016-02-21 Thread Felipe Gonçalves Assis
Make the find-renames option follow the behaviour in git-diff, where it
resets the threshold when none is given. So, for instance,
"--find-renames=25 --find-renames" should result in the default
threshold (50%) instead of 25%.

Add corresponding test.

Signed-off-by: Felipe Gonçalves Assis 
---

Now bundles the relevant test.

 merge-recursive.c | 4 +++-
 t/t3034-merge-recursive-rename-options.sh | 6 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 7bff5be..b880ae5 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2094,8 +2094,10 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o->renormalize = 0;
else if (!strcmp(s, "no-renames"))
o->detect_rename = 0;
-   else if (!strcmp(s, "find-renames"))
+   else if (!strcmp(s, "find-renames")) {
o->detect_rename = 1;
+   o->rename_score = 0;
+   }
else if (skip_prefix(s, "find-renames=", &arg) ||
 skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg 
!= 0)
diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index d4f9742..54d5f1b 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -146,6 +146,12 @@ test_expect_success 'last wins in --find-renames= 
--find-renames=' '
check_find_renames_75
 '
 
+test_expect_success '--find-renames resets threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames=25 --find-renames 
HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
 test_expect_success 'last wins in --no-renames --find-renames' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive --no-renames --find-renames HEAD^ -- 
HEAD master &&
-- 
2.7.1.492.gd821b20

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] merge-recursive: test more consistent interface

2016-02-21 Thread Felipe Gonçalves Assis
On 21 February 2016 at 15:40, Eric Sunshine  wrote:
> On Sun, Feb 21, 2016 at 10:09 AM, Felipe Gonçalves Assis
>  wrote:
>> merge-recursive: test more consistent interface
>
> The real meat of this patch (it seems) is that you're adding tests to
> verify that --find-renames= and --rename-threshold= are aliases, so it
> might make sense for the summary line to state that.
>
> t3034: test that --find-renames= and --rename-threshold= are aliases
>
>> Update basic tests to use the new option find-renames instead of
>> rename-threshold. Add tests to verify that rename-threshold= behaves
>> as a synonym for find-renames=. Test that find-renames resets
>> threshold.
>
> Likewise, the order of these sentences seems wrong. The important bit
> should be mentioned first, which is that the one is an alias for the
> other.
>
> (In fact, if you take advice given below in the actual patch content,
> then this paragraph can probably be dropped altogether since the other
> two bits don't really belong in this patch.)
>
>> Signed-off-by: Felipe Gonçalves Assis 
>> ---
>> diff --git a/t/t3034-merge-recursive-rename-options.sh 
>> b/t/t3034-merge-recursive-rename-options.sh
>> @@ -115,25 +115,25 @@ test_expect_success 'the default similarity index is 
>> 50%' '
>>
>>  test_expect_success 'low rename threshold' '
>> git read-tree --reset -u HEAD &&
>> -   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- 
>> HEAD master &&
>> +   test_must_fail git merge-recursive --find-renames=25 HEAD^ -- HEAD 
>> master &&
>
> Since you're building this series atop 10ae752 (merge-recursive:
> option to specify rename threshold, 2010-09-27) in 'next', the
> --find-renames= option already exists, so these tests, which were
> added in 3/5, can instead use --find-renames= from the start, thus
> making this patch (5/5) much less noisy since this change and several
> below will disappear altogether.
>
> Taking the above and review comments from earlier patches into
> account, it might make sense to re-order the series as follows:
>
> 1/5: add --find-renames & --find-renames= tests (including "last wins")
> 2/5: add --find-renames= / --rename-threshold= aliases tests
> 3/5: add --no-renames tests (including "last wins")
> 4/5: fix --find-renames to reset threshold to default (including test)
> 5/5: fix merge-strategies.txt typo
>
> The position of the typo fix patch isn't significant; I just
> arbitrarily plopped it at the end. Also, the order of patches 2 & 3 is
> arbitrary.
>

Fair enough. As I said, I ordered the three test commits so that the
first one could be applied soon after the commit introducing
"rename-thresholds", the second soon after the commit introducing
"no-renames" and the third one soon after the fixup for the commit
introducing "find-renames" (which would ideally be correct from the
start), but then this is probably more aesthetic than practical.

I am currently working on the following order, which follows your constraints.
1/5: fix typo (I don't like typos)
2/5: tests involving --find-renames
3/5: tests involving --no-renames
4/5: tests involving --rename-threshold (this represents what would be
reverted if the feature was discontinued)
5/5: fix --find-renames + test

> More below...
>
>
>> +test_expect_success 'last wins in --no-renames --find-renames' '
>> +   git read-tree --reset -u HEAD &&
>> +   test_must_fail git merge-recursive --no-renames --find-renames HEAD^ 
>> -- HEAD master &&
>> +   check_find_renames_50
>> +'
>> +
>> +test_expect_success 'last wins in --find-renames --no-renames' '
>> +   git read-tree --reset -u HEAD &&
>> +   git merge-recursive --find-renames --no-renames HEAD^ -- HEAD master 
>> &&
>> +   check_no_renames
>> +'
>> +
>> +test_expect_success 'rename-threshold= is a synonym for 
>> find-renames=' '
>> +   git read-tree --reset -u HEAD &&
>> +   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- 
>> HEAD master &&
>> +   check_find_renames_25
>> +'
>
> I rather expected to see this test come first, as all the others are
> rather subordinate to it.
>

But it already is the first test involving "rename-threshold". The
preceding tests verify the rename detection functionality with the
recommended interface. Then we have tests for the deprecated option.
This tail is exactly what we wou

Re: [PATCH 3/5] merge-recursive: test rename threshold option

2016-02-21 Thread Felipe Gonçalves Assis
On 21 February 2016 at 14:52, Eric Sunshine  wrote:
> On Sun, Feb 21, 2016 at 10:09 AM, Felipe Gonçalves Assis
>  wrote:
>> merge-recursive: test rename threshold option
>
>> +   git read-tree --reset -u HEAD &&
>> +   test_must_fail git merge-recursive HEAD^ -- HEAD master &&
>> +   check_find_renames_50
>> +'
>> +
>> +test_expect_success 'low rename threshold' '
>> +   git read-tree --reset -u HEAD &&
>> +   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- 
>> HEAD master &&
>> +   check_find_renames_25
>> [...]
>> +   check_find_renames_75
>> [...]
>> +   check_find_renames_100
>> +'
>> +
>> +test_expect_success 'rename threshold is truncated' '
>> +   git read-tree --reset -u HEAD &&
>> +   test_must_fail git merge-recursive --rename-threshold=200% HEAD^ -- 
>> HEAD master &&
>> +   check_find_renames_100
>> +'
>
> Is this truncation documented behavior or is it just a detail of the
> current implementation. (Genuine question; I haven't checked the
> documentation or source.) If just an implementation detail, then it
> might not be desirable to formalize it via a test.
>

Not documented. I will remove this. If you prefer to have it
documented and the test added back later, I can do that.

>> +test_expect_success 'last wins in --rename-threshold= 
>> --rename-threshold=' '
>> +   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
>> +'
>
> Would it make sense to add tests checking that invalid
> --rename-threshold= arguments, such as negative and non-numbers,
> correctly error out?
>

I guess so. Can I ask you for a suggestion on how to check this?

Given that merges here usually fail anyway because of the conflicts,
what is the best way of checking the effect of an argument rejection?
1. Check that the merge fails but the index is not changed
2. Check for a specific exit code
3. Use another setup so that the merges succeed


Thanks for the detailed review. Already working on the other comments.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] merge-strategies.txt: fix typo

2016-02-21 Thread Felipe Gonçalves Assis
Signed-off-by: Felipe Gonçalves Assis 
---
 Documentation/merge-strategies.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index ff359b6..2eb92b9 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -86,8 +86,8 @@ no-renames;;
See also linkgit:git-diff[1] `--no-renames`.
 
 find-renames[=];;
-   Turn on rename detection, optionally setting the the similarity
-   threshold. This is the default.
+   Turn on rename detection, optionally setting the similarity
+   threshold.  This is the default.
See also linkgit:git-diff[1] `--find-renames`.
 
 rename-threshold=;;
-- 
2.7.1.492.gc9722f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] merge-recursive: find-renames resets threshold

2016-02-21 Thread Felipe Gonçalves Assis
Make the find-renames option follow the behaviour in git-diff, where it
resets the threshold when none is given. So, for instance,
"--find-renames=25 --find-renames" should result in the default
threshold (50%) instead of 25%.

Signed-off-by: Felipe Gonçalves Assis 
---
 merge-recursive.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 7bff5be..b880ae5 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2094,8 +2094,10 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o->renormalize = 0;
else if (!strcmp(s, "no-renames"))
o->detect_rename = 0;
-   else if (!strcmp(s, "find-renames"))
+   else if (!strcmp(s, "find-renames")) {
o->detect_rename = 1;
+   o->rename_score = 0;
+   }
else if (skip_prefix(s, "find-renames=", &arg) ||
 skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg 
!= 0)
-- 
2.7.1.492.gc9722f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] merge-recursive: test more consistent interface

2016-02-21 Thread Felipe Gonçalves Assis
Update basic tests to use the new option find-renames instead of
rename-threshold. Add tests to verify that rename-threshold= behaves
as a synonym for find-renames=. Test that find-renames resets
threshold.

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-options.sh | 48 +++
 1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 2f10fa7..7fea7bd 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -115,25 +115,25 @@ test_expect_success 'the default similarity index is 50%' 
'
 
 test_expect_success 'low rename threshold' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   test_must_fail git merge-recursive --find-renames=25 HEAD^ -- HEAD 
master &&
check_find_renames_25
 '
 
 test_expect_success 'high rename threshold' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=75 HEAD^ -- HEAD 
master &&
+   test_must_fail git merge-recursive --find-renames=75 HEAD^ -- HEAD 
master &&
check_find_renames_75
 '
 
 test_expect_success 'exact renames only' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=100% HEAD^ -- 
HEAD master &&
+   test_must_fail git merge-recursive --find-renames=100% HEAD^ -- HEAD 
master &&
check_find_renames_100
 '
 
 test_expect_success 'rename threshold is truncated' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=200% HEAD^ -- 
HEAD master &&
+   test_must_fail git merge-recursive --find-renames=200% HEAD^ -- HEAD 
master &&
check_find_renames_100
 '
 
@@ -143,12 +143,36 @@ test_expect_success 'disabled rename detection' '
check_no_renames
 '
 
-test_expect_success 'last wins in --rename-threshold= 
--rename-threshold=' '
+test_expect_success 'last wins in --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=25 
--rename-threshold=75 HEAD^ -- HEAD master &&
+   test_must_fail git merge-recursive --find-renames=25 --find-renames=75 
HEAD^ -- HEAD master &&
check_find_renames_75
 '
 
+test_expect_success '--find-renames resets threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames=25 --find-renames 
HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --no-renames --find-renames HEAD^ -- 
HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'last wins in --find-renames --no-renames' '
+   git read-tree --reset -u HEAD &&
+   git merge-recursive --find-renames --no-renames HEAD^ -- HEAD master &&
+   check_no_renames
+'
+
+test_expect_success 'rename-threshold= is a synonym for find-renames=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   check_find_renames_25
+'
+
 test_expect_success 'last wins in --no-renames --rename-threshold=' '
git read-tree --reset -u HEAD &&
test_must_fail git merge-recursive --no-renames --rename-threshold=25 
HEAD^ -- HEAD master &&
@@ -161,4 +185,16 @@ test_expect_success 'last wins in --rename-threshold= 
--no-renames' '
check_no_renames
 '
 
+test_expect_success 'last wins in --rename-threshold= --find-renames' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 --find-renames 
HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'last wins in --find-renames --rename-threshold=' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames --rename-threshold=25 
HEAD^ -- HEAD master &&
+   check_find_renames_25
+'
+
 test_done
-- 
2.7.1.492.gc9722f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] merge-recursive: test option to disable renames

2016-02-21 Thread Felipe Gonçalves Assis
Also update name and description of tests for consistency:
"merge-recursive options"  -> "merge-recursive space options"
"merge-recursive rename threshold" -> "merge-recursive rename options"

Signed-off-by: Felipe Gonçalves Assis 
---
 ...ons.sh => t3032-merge-recursive-space-options.sh} |  2 +-
 ...ld.sh => t3034-merge-recursive-rename-options.sh} | 20 +++-
 2 files changed, 20 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/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= 
--rename-threshold=' '
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=' '
+   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= --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.492.gc9722f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] merge-recursive: test rename threshold option

2016-02-21 Thread Felipe Gonçalves Assis
Commit 10ae7526bebb505ba01f76ec97d5f7b5e0e5 introduced this feature,
but did not include any tests. This commit fixes this.

Signed-off-by: Felipe Gonçalves Assis 
---
 t/t3034-merge-recursive-rename-threshold.sh | 146 
 1 file changed, 146 insertions(+)
 create mode 100755 t/t3034-merge-recursive-rename-threshold.sh

diff --git a/t/t3034-merge-recursive-rename-threshold.sh 
b/t/t3034-merge-recursive-rename-threshold.sh
new file mode 100755
index 000..f0b3f44
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-threshold.sh
@@ -0,0 +1,146 @@
+#!/bin/sh
+
+test_description='merge-recursive rename threshold option
+
+Test rename detection by examining rename/delete conflicts.
+
+Similarity index:
+R100 a-old a-new
+R075 b-old b-new
+R050 c-old c-new
+R025 d-old d-new
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+   get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new > expected-stages-undetected-$1
+   sed "s/ 0   / 2 /
+   " < expected-stages-undetected-$1 > expected-stages-detected-$1
+   git read-tree -u --reset HEAD
+   } &&
+
+   rename_detected () {
+   git ls-files --stage $1-old $1-new > stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+   } &&
+
+   rename_undetected () {
+   git ls-files --stage $1-old $1-new > stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+   } &&
+
+   check_common () {
+   git ls-files --stage > stages-actual &&
+   test $(wc -l < stages-actual) -eq 4
+   } &&
+
+   check_find_renames_25 () {
+   check_common &&
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_detected d
+   } &&
+
+   check_find_renames_50 () {
+   check_common
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_undetected d
+   } &&
+
+   check_find_renames_75 () {
+   check_common
+   rename_detected a &&
+   rename_detected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   check_find_renames_100 () {
+   check_common
+   rename_detected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   check_no_renames () {
+   check_common
+   rename_undetected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   cat <<-\EOF > a-old &&
+   aa1
+   aa2
+   aa3
+   aa4
+   EOF
+   sed s/aa/bb/ < a-old > b-old &&
+   sed s/aa/cc/ < a-old > c-old &&
+   sed s/aa/dd/ < a-old > d-old &&
+   git add [a-d]-old &&
+   test_tick &&
+   git commit -m base &&
+   git rm [a-d]-old &&
+   test_tick &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp a-old a-new &&
+   sed 1,1s/./x/ < b-old > b-new &&
+   sed 1,2s/./x/ < c-old > c-new &&
+   sed 1,3s/./x/ < d-old > d-new &&
+   git add [a-d]-new &&
+   git rm [a-d]-old &&
+   test_tick &&
+   git commit -m rename &&
+   get_expected_stages a &&
+   get_expected_stages b &&
+   get_expected_stages c &&
+   get_expected_stages d
+'
+
+test_expect_success 'the default similarity index is 50%' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'low rename threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   check_find_renames_25
+'
+
+test_expect_success 'high rename threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=75 HEAD^ -- HEAD 
master &&
+   check_find_renames_75
+'
+
+test_expect_success 'exact renames only' &

[PATCH 0/5] Tests and fixes for merge-recursive rename options

2016-02-21 Thread Felipe Gonçalves Assis
This builds on the work in 1b47ad160b55f50a7a98c180e18d80f0f8f17a67
(merge-recursive: more consistent interface, 2016-02-17).

Add tests for the merge-recursive rename options, as suggested by Eric Sunshine.
Also fixes an inconsistency in the behaviour of find-renames and a typo.

The first two commits contain fixes.

The tests were divided in the latter three, reproducing the chronological
history of the features:
  3. --rename-threshold only
  4. --rename-threshold and --no-renames
  5. --find-renames, --no-renames and deprecated --rename-threshold

Felipe Gonçalves Assis (5):
  merge-recursive: find-renames resets threshold
  merge-strategies.txt: fix typo
  merge-recursive: test rename threshold option
  merge-recursive: test option to disable renames
  merge-recursive: test more consistent interface

 Documentation/merge-strategies.txt |   4 +-
 merge-recursive.c  |   4 +-
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 200 +
 4 files changed, 206 insertions(+), 4 deletions(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.492.gc9722f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/3] merge-recursive: option to disable renames

2016-02-21 Thread Felipe Gonçalves Assis
On 21 February 2016 at 04:40, Junio C Hamano  wrote:
> Yikes, your previous round is already in 'next', so could you make
> this series an incremental on top of what is already queued up to
> 1b47ad16 (merge-recursive: more consistent interface, 2016-02-17)?
>
> Thanks.
>

Oh, sorry. I did not notice that. I will submit a new series shortly.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/3] merge-recursive: test rename threshold option

2016-02-20 Thread Felipe Gonçalves Assis
Commit 10ae7526bebb505ba01f76ec97d5f7b5e0e5 introduced this feature,
but did not include any tests. This commit fixes this.

Signed-off-by: Felipe Gonçalves Assis 
---

This commit is independent of the proposed feature, so it might be of interest
even if the rest of the patch is rejected.

 t/t3034-merge-recursive-rename-threshold.sh | 146 
 1 file changed, 146 insertions(+)
 create mode 100755 t/t3034-merge-recursive-rename-threshold.sh

diff --git a/t/t3034-merge-recursive-rename-threshold.sh 
b/t/t3034-merge-recursive-rename-threshold.sh
new file mode 100755
index 000..f0b3f44
--- /dev/null
+++ b/t/t3034-merge-recursive-rename-threshold.sh
@@ -0,0 +1,146 @@
+#!/bin/sh
+
+test_description='merge-recursive rename threshold option
+
+Test rename detection by examining rename/delete conflicts.
+
+Similarity index:
+R100 a-old a-new
+R075 b-old b-new
+R050 c-old c-new
+R025 d-old d-new
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+   get_expected_stages () {
+   git checkout rename -- $1-new &&
+   git ls-files --stage $1-new > expected-stages-undetected-$1
+   sed "s/ 0   / 2 /
+   " < expected-stages-undetected-$1 > expected-stages-detected-$1
+   git read-tree -u --reset HEAD
+   } &&
+
+   rename_detected () {
+   git ls-files --stage $1-old $1-new > stages-actual-$1 &&
+   test_cmp expected-stages-detected-$1 stages-actual-$1
+   } &&
+
+   rename_undetected () {
+   git ls-files --stage $1-old $1-new > stages-actual-$1 &&
+   test_cmp expected-stages-undetected-$1 stages-actual-$1
+   } &&
+
+   check_common () {
+   git ls-files --stage > stages-actual &&
+   test $(wc -l < stages-actual) -eq 4
+   } &&
+
+   check_find_renames_25 () {
+   check_common &&
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_detected d
+   } &&
+
+   check_find_renames_50 () {
+   check_common
+   rename_detected a &&
+   rename_detected b &&
+   rename_detected c &&
+   rename_undetected d
+   } &&
+
+   check_find_renames_75 () {
+   check_common
+   rename_detected a &&
+   rename_detected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   check_find_renames_100 () {
+   check_common
+   rename_detected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   check_no_renames () {
+   check_common
+   rename_undetected a &&
+   rename_undetected b &&
+   rename_undetected c &&
+   rename_undetected d
+   } &&
+
+   cat <<-\EOF > a-old &&
+   aa1
+   aa2
+   aa3
+   aa4
+   EOF
+   sed s/aa/bb/ < a-old > b-old &&
+   sed s/aa/cc/ < a-old > c-old &&
+   sed s/aa/dd/ < a-old > d-old &&
+   git add [a-d]-old &&
+   test_tick &&
+   git commit -m base &&
+   git rm [a-d]-old &&
+   test_tick &&
+   git commit -m delete &&
+   git checkout -b rename HEAD^ &&
+   cp a-old a-new &&
+   sed 1,1s/./x/ < b-old > b-new &&
+   sed 1,2s/./x/ < c-old > c-new &&
+   sed 1,3s/./x/ < d-old > d-new &&
+   git add [a-d]-new &&
+   git rm [a-d]-old &&
+   test_tick &&
+   git commit -m rename &&
+   get_expected_stages a &&
+   get_expected_stages b &&
+   get_expected_stages c &&
+   get_expected_stages d
+'
+
+test_expect_success 'the default similarity index is 50%' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'low rename threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   check_find_renames_25
+'
+
+test_expect_success 'high rename threshold' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --rename-threshold=75 HEAD^ -- HEAD 

[PATCH v5 2/3] merge-recursive: option to disable renames

2016-02-20 Thread Felipe Gonçalves Assis
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 
---

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=;;
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[=];;
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= 
--rename-threshold=' '
g

[PATCH v5 3/3] merge-recursive: more consistent interface

2016-02-20 Thread Felipe Gonçalves Assis
Add strategy option find-renames, following git-diff interface. This
makes the option rename-threshold redundant.

Signed-off-by: Felipe Gonçalves Assis 
---

Added tests and made --find-renames reset the similarity index to the default.

 Documentation/merge-strategies.txt| 10 ---
 merge-recursive.c |  7 -
 t/t3034-merge-recursive-rename-options.sh | 48 +++
 3 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index 1a5e197..2eb92b9 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -85,11 +85,13 @@ no-renames;;
Turn off rename detection.
See also linkgit:git-diff[1] `--no-renames`.
 
+find-renames[=];;
+   Turn on rename detection, optionally setting the similarity
+   threshold.  This is the default.
+   See also linkgit:git-diff[1] `--find-renames`.
+
 rename-threshold=;;
-   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`.
+   Deprecated synonym for `find-renames=`.
 
 subtree[=];;
This option is a more advanced form of 'subtree' strategy, where
diff --git a/merge-recursive.c b/merge-recursive.c
index 6dd0a11..63b8ba8 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2094,7 +2094,12 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o->renormalize = 0;
else if (!strcmp(s, "no-renames"))
o->detect_rename = 0;
-   else if (skip_prefix(s, "rename-threshold=", &arg)) {
+   else if (!strcmp(s, "find-renames")) {
+   o->detect_rename = 1;
+   o->rename_score = 0;
+   }
+   else if (skip_prefix(s, "find-renames=", &arg) ||
+skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg 
!= 0)
return -1;
o->detect_rename = 1;
diff --git a/t/t3034-merge-recursive-rename-options.sh 
b/t/t3034-merge-recursive-rename-options.sh
index 2f10fa7..4e3fefd 100755
--- a/t/t3034-merge-recursive-rename-options.sh
+++ b/t/t3034-merge-recursive-rename-options.sh
@@ -115,25 +115,25 @@ test_expect_success 'the default similarity index is 50%' 
'
 
 test_expect_success 'low rename threshold' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=25 HEAD^ -- HEAD 
master &&
+   test_must_fail git merge-recursive --find-renames=25 HEAD^ -- HEAD 
master &&
check_find_renames_25
 '
 
 test_expect_success 'high rename threshold' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=75 HEAD^ -- HEAD 
master &&
+   test_must_fail git merge-recursive --find-renames=75 HEAD^ -- HEAD 
master &&
check_find_renames_75
 '
 
 test_expect_success 'exact renames only' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=100% HEAD^ -- 
HEAD master &&
+   test_must_fail git merge-recursive --find-renames=100% HEAD^ -- HEAD 
master &&
check_find_renames_100
 '
 
 test_expect_success 'rename threshold is truncated' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=200% HEAD^ -- 
HEAD master &&
+   test_must_fail git merge-recursive --find-renames=200% HEAD^ -- HEAD 
master &&
check_find_renames_100
 '
 
@@ -143,12 +143,36 @@ test_expect_success 'disabled rename detection' '
check_no_renames
 '
 
-test_expect_success 'last wins in --rename-threshold= 
--rename-threshold=' '
+test_expect_success 'last wins in --find-renames= --find-renames=' '
git read-tree --reset -u HEAD &&
-   test_must_fail git merge-recursive --rename-threshold=25 
--rename-threshold=75 HEAD^ -- HEAD master &&
+   test_must_fail git merge-recursive --find-renames=25 --find-renames=75 
HEAD^ -- HEAD master &&
check_find_renames_75
 '
 
+test_expect_success '--find-renames is equivalent to --find-renames=5' '
+   git read-tree --reset -u HEAD &&
+   test_must_fail git merge-recursive --find-renames=25 --find-renames 
HEAD^ -- HEAD master &&
+   check_find_renames_50
+'
+
+test_expect_success 'last wins in --no-renames --find-renames' '
+   git read-tree --reset -u HEAD &

[PATCH v5 0/3] merge-recursive: option to disable renames

2016-02-20 Thread Felipe Gonçalves Assis
Add tests as suggested by Eric Sunshine. Also fixes an inconsitency in the last
part.

Since there were no tests for the --rename-threshold option, I added them in a
separate commit, which is useful in itself.

The other two commits contain the previous patches plus the relevant tests.

For the last part, I made --find-renames (without =) reset the similarity
index to the default, just as in git-diff.

Felipe Gonçalves Assis (3):
  merge-recursive: test rename threshold option
  merge-recursive: option to disable renames
  merge-recursive: more consistent interface

 Documentation/merge-strategies.txt |  12 +-
 merge-recursive.c  |  14 +-
 merge-recursive.h  |   1 +
 ...s.sh => t3032-merge-recursive-space-options.sh} |   2 +-
 t/t3034-merge-recursive-rename-options.sh  | 200 +
 5 files changed, 225 insertions(+), 4 deletions(-)
 rename t/{t3032-merge-recursive-options.sh => 
t3032-merge-recursive-space-options.sh} (99%)
 create mode 100755 t/t3034-merge-recursive-rename-options.sh

-- 
2.7.1.342.gf5bb636

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
On 16 February 2016 at 23:37, Eric Sunshine  wrote:
> On Tue, Feb 16, 2016 at 8:11 PM, Felipe Gonçalves Assis
>  wrote:
>> No more renames option. rename-threshold enables renames.
>
> Can you add some tests? Off the top of my head, I'd expect to see at
> least three new tests:
>
> 1. --no-renames works as expected
> 2. last wins in "--no-renames --rename-threshold=x"
> 3. last wins in "--rename-threshold=x --no-renames"
>

Sure.

Just a heads up: For the next three days I will have very little time,
so I will start tackling this on the weekend. I submitted a fourth
version of the patch without the tests, so that this part of the work
can proceed in parallel.

Thanks,
Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
Incorporate documentation input from Eric Sunshine. Fix missing signoff.

The first part is unchanged.

No tests are included for now. This work is being done in parallel and should
be properly included in future proposals.

Felipe Gonçalves Assis (2):
  merge-recursive: option to disable renames
  merge-recursive: more consistent interface

 Documentation/merge-strategies.txt | 12 ++--
 merge-recursive.c  | 12 +++-
 merge-recursive.h  |  1 +
 3 files changed, 22 insertions(+), 3 deletions(-)

-- 
2.7.1.289.ga0c045c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
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 
---
 Documentation/merge-strategies.txt | 6 ++
 merge-recursive.c  | 7 +++
 merge-recursive.h  | 1 +
 3 files changed, 14 insertions(+)

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=;;
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[=];;
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;
-- 
2.7.1.289.ga0c045c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/2] merge-recursive: more consistent interface

2016-02-16 Thread Felipe Gonçalves Assis
Add strategy option find-renames, following git-diff interface. This
makes the option rename-threshold redundant.

Signed-off-by: Felipe Gonçalves Assis 
---
 Documentation/merge-strategies.txt | 10 ++
 merge-recursive.c  |  5 -
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index 1a5e197..ff359b6 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -85,11 +85,13 @@ no-renames;;
Turn off rename detection.
See also linkgit:git-diff[1] `--no-renames`.
 
+find-renames[=];;
+   Turn on rename detection, optionally setting the the similarity
+   threshold. This is the default.
+   See also linkgit:git-diff[1] `--find-renames`.
+
 rename-threshold=;;
-   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`.
+   Deprecated synonym for `find-renames=`.
 
 subtree[=];;
This option is a more advanced form of 'subtree' strategy, where
diff --git a/merge-recursive.c b/merge-recursive.c
index 6dd0a11..700febd 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2094,7 +2094,10 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o->renormalize = 0;
else if (!strcmp(s, "no-renames"))
o->detect_rename = 0;
-   else if (skip_prefix(s, "rename-threshold=", &arg)) {
+   else if (!strcmp(s, "find-renames"))
+   o->detect_rename = 1;
+   else if (skip_prefix(s, "find-renames=", &arg) ||
+skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg 
!= 0)
return -1;
o->detect_rename = 1;
-- 
2.7.1.289.ga0c045c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
On 16 February 2016 at 23:41, Eric Sunshine  wrote:
> On Tue, Feb 16, 2016 at 8:11 PM, Felipe Gonçalves Assis
>  wrote:
>> 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 
>> ---
>> diff --git a/Documentation/merge-strategies.txt 
>> b/Documentation/merge-strategies.txt
>> @@ -81,8 +81,14 @@ no-renormalize;;
>> +no-renames;;
>> +   Turn off rename detection.
>> +   See also linkgit:git-diff[1] `--no-renames`.
>> +
>>  rename-threshold=;;
>> Controls the similarity threshold used for rename detection.
>> +   Re-enables rename detection if disabled by a preceding
>> +   `no-renames`.
>
> I'm not sure that it is necessary to mention the "last one wins" rule
> here, but if you do so, does --no-renames documentation deserve
> similar treatment?
>

It is not so much about the "last one wins" rule, but about the fact
that, given the sub-optimal name, it is not obvious that this option
even enables renaming. The wording is just the best way I found to
explain that without creating additional confusion.

I will apply your suggestion on the second commit. Please see the next
patch proposal and tell what you think.

Thanks,
Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
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 
---
 Documentation/merge-strategies.txt | 6 ++
 merge-recursive.c  | 7 +++
 merge-recursive.h  | 1 +
 3 files changed, 14 insertions(+)

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=;;
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[=];;
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;
-- 
2.7.1.288.gfad33a8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
No more renames option. rename-threshold enables renames.

detect_rename is now a simple boolean. Its value is no longer linked to
DIFF_ANYTHING symbol.

A second optional patch is included, teaching merge-recursive to take
"find-renames[=]" as well, for consistency.

Felipe Gonçalves Assis (2):
  merge-recursive: option to disable renames
  merge-recursive: more consistent interface

 Documentation/merge-strategies.txt | 14 --
 merge-recursive.c  | 12 +++-
 merge-recursive.h  |  1 +
 3 files changed, 24 insertions(+), 3 deletions(-)

-- 
2.7.1.288.gfad33a8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/2] merge-recursive: more consistent interface

2016-02-16 Thread Felipe Gonçalves Assis
Add strategy option find-renames, following git-diff interface. This
makes the option rename-threshold redundant.
---

A minor note
git diff --check complains about an indent with spaces here, but I think I did
the right thing: indented with tabs and aligned with spaces. If desired, I can
align with tabs to avoid this.

 Documentation/merge-strategies.txt | 8 ++--
 merge-recursive.c  | 5 -
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index 1a5e197..f8618c9 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -85,11 +85,15 @@ no-renames;;
Turn off rename detection.
See also linkgit:git-diff[1] `--no-renames`.
 
-rename-threshold=;;
+find-renames[=];;
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`.
+   See also linkgit:git-diff[1] `--find-renames`.
+
+rename-threshold=;;
+   Synonym for `find-renames=`. Present for historical reasons.
+   New scripts should prefer the `find-renames=` syntax.
 
 subtree[=];;
This option is a more advanced form of 'subtree' strategy, where
diff --git a/merge-recursive.c b/merge-recursive.c
index 6dd0a11..700febd 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2094,7 +2094,10 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o->renormalize = 0;
else if (!strcmp(s, "no-renames"))
o->detect_rename = 0;
-   else if (skip_prefix(s, "rename-threshold=", &arg)) {
+   else if (!strcmp(s, "find-renames"))
+   o->detect_rename = 1;
+   else if (skip_prefix(s, "find-renames=", &arg) ||
+skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg 
!= 0)
return -1;
o->detect_rename = 1;
-- 
2.7.1.288.gfad33a8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
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 
---

Following Hamano's review, this patch includes a strategy option "renames" and
simplifies the implementation.

Also note merge-recursive.c:492, where I forward detect_rename from the merge
options to the diff options, instead of hardcoding it to DIFF_DETECT_RENAME,
which could cause surprises in the future.

 Documentation/merge-strategies.txt |  9 +
 merge-recursive.c  | 10 +-
 merge-recursive.h  |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index 7bbd19b..f794d23 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -81,6 +81,15 @@ no-renormalize;;
Disables the `renormalize` option.  This overrides the
`merge.renormalize` configuration variable.
 
+renames;;
+   Turn on rename detection.
+   This is the default.
+   See also linkgit:git-diff[1] `-M`.
+
+no-renames;;
+   Turn off rename detection.
+   See also linkgit:git-diff[1] `--no-renames`.
+
 rename-threshold=;;
Controls the similarity threshold used for rename detection.
See also linkgit:git-diff[1] `-M`.
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..2f9c40a 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -482,10 +482,13 @@ 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);
-   opts.detect_rename = DIFF_DETECT_RENAME;
+   opts.detect_rename = o->detect_rename;
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
1000;
@@ -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 = DIFF_DETECT_RENAME;
merge_recursive_config(o);
if (getenv("GIT_MERGE_VERBOSITY"))
o->verbosity =
@@ -2088,6 +2092,10 @@ 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, "renames"))
+   o->detect_rename = DIFF_DETECT_RENAME;
+   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;
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;
-- 
2.7.1.288.g6752e66

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] merge-recursive: option to disable renames

2016-02-16 Thread Felipe Gonçalves Assis
On 16 February 2016 at 19:49, Junio C Hamano  wrote:
> "Felipe Gonçalves Assis"   writes:
>
>> +no-renames;;
>> + Turn off rename detection.
>> + See also linkgit:git-diff[1] `--no-renames`.
>
> Even though by default for merge-recursive the rename detection is
> on, if we are adding an option to control this aspect of the
> behaviour from the command line, it should follow the usual pattern,
> i.e.
>
>  (1) the code to parse options would allow an earlier "--no-renames"
>  on the command line to be overridden with a later "--renames"; and
>
>  (2) the description in the documentation would be headed by
>  "--[no-]renames", describes which one is the default, etc.
>

Just a note: In git-diff, there is no "--renames". Instead, renames
are enabled by the "--find-renames[=]" option.

1. Do you think "rename-threshold=" should enable renames?
2. Should we have an option "find-renames" in merge?
3. Should git-diff have a "--renames" option?

I personally like your suggestion as it is. Just wanted to make sure
you considered that while I work on the next patch.

Thanks,
Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Custom merge driver with no rename detection

2016-02-15 Thread Felipe Gonçalves Assis
On 15 February 2016 at 09:03, Junio C Hamano  wrote:
> Felipe Gonçalves Assis  writes:
>
>> However, if you do find this approach acceptable/desirable
>> (rename-threshold > 100%), I can work on the issues pointed out and
>> propose a proper patch.
>
> The caller asks diffcore-rename to detect rename, and the algorithm
> compares things to come up with a similarity score and match things
> up.  And you add an option to the rename detection logic to forbid
> finding any?
>
> To be bluntly honest, the approach sounds like a crazy talk.
>
> If your goal is not to allow rename detection at all, why not teach
> the caller of the diff machinery not to even ask for rename
> detection at all?  merge-recursive.c has a helper function called
> get_renames(), and it calls into the diff machinery passing
> DIFF_DETECT_RENAME option.  As a dirty hack, I think you would
> achieve your desired result if you stop passing that option there.
>
> I called that a "dirty hack", because for the purpose of not
> allowing rename detection inside merge-recursive, I think an even
> better thing to do is to teach the get_renames() helper to report to
> its caller, under your new option, "I found no renames at all"
> without doing anything.
>
> It might be just a simple matter of teaching its callers (there
> probably are two of them, one between the common ancestor and our
> branch and the other between the common ancestor and their branch)
> not call the get_renames() helper at all under your new option, but
> I didn't check these callers closely.

Thanks for all the ideas. In order to have something concrete to
discuss, I submitted the patch "merge-recursive: option to disable
renames".

Is that what you had in mind? I would be happy to receive comments and
either improve it or try something else.

Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] merge-recursive: option to disable renames

2016-02-15 Thread Felipe Gonçalves Assis
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 
---

Hi, this is a patch relative to the "Custom merge driver with no rename
detection" thread, based on suggestions by Junio C Hamano.

 Documentation/merge-strategies.txt |  4 
 merge-recursive.c  | 16 +---
 merge-recursive.h  |  1 +
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Documentation/merge-strategies.txt 
b/Documentation/merge-strategies.txt
index 7bbd19b..0528d85 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -81,6 +81,10 @@ 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=;;
Controls the similarity threshold used for rename detection.
See also linkgit:git-diff[1] `-M`.
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..ca67805 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1839,9 +1839,16 @@ int merge_trees(struct merge_options *o,
 
entries = get_unmerged();
record_df_conflict_files(o, entries);
-   re_head  = get_renames(o, head, common, head, merge, entries);
-   re_merge = get_renames(o, merge, common, head, merge, entries);
-   clean = process_renames(o, re_head, re_merge);
+   if (o->detect_rename) {
+   re_head  = get_renames(o, head, common, head, merge, 
entries);
+   re_merge = get_renames(o, merge, common, head, merge, 
entries);
+   clean = process_renames(o, re_head, re_merge);
+   }
+   else {
+   re_head  = xcalloc(1, sizeof(struct string_list));
+   re_merge = xcalloc(1, sizeof(struct string_list));
+   clean = 1;
+   }
for (i = entries->nr-1; 0 <= i; i--) {
const char *path = entries->items[i].string;
struct stage_data *e = entries->items[i].util;
@@ -2039,6 +2046,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 = DIFF_DETECT_RENAME;
merge_recursive_config(o);
if (getenv("GIT_MERGE_VERBOSITY"))
o->verbosity =
@@ -2088,6 +2096,8 @@ 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;
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;
-- 
2.7.1.291.gd6478c6

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Custom merge driver with no rename detection

2016-02-15 Thread Felipe Gonçalves Assis
On 15 February 2016 at 06:06, Johannes Schindelin
 wrote:
> Hi Felipe,
>
> On Sun, 14 Feb 2016, Felipe Gonçalves Assis wrote:
>
>> Attached is a quick and dirty patch that emulates the effect by
>> allowing greater than 100% rename thresholds to mean "no-renames".
>
> It is really hard to comment on attached patches.
>
> First comment: the commit message is awfully empty, and lacks a sign-off.
>

Thanks. I am sorry for not submitting the patch separately in an
email, but, it was really not meant for serious review, just for
emulating the desired effect with minimal effort.

However, if you do find this approach acceptable/desirable
(rename-threshold > 100%), I can work on the issues pointed out and
propose a proper patch.

Regards,
Felipe
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Custom merge driver with no rename detection

2016-02-14 Thread Felipe Gonçalves Assis
Hi,

I would like to set up a Git repository with a custom merge driver,
and then disable rename detection when merging.

Unfortunately, the recursive strategy has no "no-renames" option. Note
that I would like to avoid rename detection even when the file
contents perfectly match.

The usual workaround is using the resolve strategy, but apparently it
ignores the custom merge driver. Besides, I would really like to use
the recursive strategy logic.

Is there any solution to this in the current version?

If not, what do you think about adding a "no-renames" option to the
recursive strategy? I could work on a patch.

Attached is a quick and dirty patch that emulates the effect by
allowing greater than 100% rename thresholds to mean "no-renames".

And here is a related question on StackOverflow:
http://stackoverflow.com/questions/35135517/custom-git-merge-driver-with-no-rename-detection

Thanks in advance for any attention provided.

Regards,
Felipe Gonçalves Assis
From bcef6c44fac3a29afe03408ef27024776da861ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felipe=20Gon=C3=A7alves=20Assis?= 
Date: Sun, 14 Feb 2016 17:02:00 -0200
Subject: [PATCH] diff: rename threshold above 100% means no renames

---
 diff.c| 2 +-
 diffcore-rename.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index 2136b69..43b9e0a 100644
--- a/diff.c
+++ b/diff.c
@@ -4003,7 +4003,7 @@ int parse_rename_score(const char **cp_p)
 	/* user says num divided by scale and we say internally that
 	 * is MAX_SCORE * num / scale.
 	 */
-	return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
+	return (int)(MAX_SCORE * num / scale);
 }
 
 static int diff_scoreopt_parse(const char *opt)
diff --git a/diffcore-rename.c b/diffcore-rename.c
index af1fe08..7cb5a3b 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -497,7 +497,7 @@ void diffcore_rename(struct diff_options *options)
 			register_rename_src(p);
 		}
 	}
-	if (rename_dst_nr == 0 || rename_src_nr == 0)
+	if (rename_dst_nr == 0 || rename_src_nr == 0 || minimum_score > MAX_SCORE)
 		goto cleanup; /* nothing to do */
 
 	/*
-- 
2.7.1.287.g4943984