From: "Felipe Gonçalves Assis" <felipeg.assis@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, gitster@pobox.com,
sunshine@sunshineco.com,
"Felipe Gonçalves Assis" <felipegassis@gmail.com>
Subject: [PATCH v5 1/3] merge-recursive: test rename threshold option
Date: Sat, 20 Feb 2016 23:34:30 -0300 [thread overview]
Message-ID: <1456022072-5342-2-git-send-email-felipegassis@gmail.com> (raw)
In-Reply-To: <1456022072-5342-1-git-send-email-felipegassis@gmail.com>
Commit 10ae7526bebb505ddddba01f76ec97d5f7b5e0e5 introduced this feature,
but did not include any tests. This commit fixes this.
Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
---
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 0000000..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' '
+ git read-tree --reset -u HEAD &&
+ test_must_fail git merge-recursive --rename-threshold=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 &&
+ check_find_renames_100
+'
+
+test_expect_success 'last wins in --rename-threshold=<m> --rename-threshold=<n>' '
+ git read-tree --reset -u HEAD &&
+ test_must_fail git merge-recursive --rename-threshold=25 --rename-threshold=75 HEAD^ -- HEAD master &&
+ check_find_renames_75
+'
+
+test_done
--
2.7.1.342.gf5bb636
next prev parent reply other threads:[~2016-02-21 2:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-21 2:34 [PATCH v5 0/3] merge-recursive: option to disable renames Felipe Gonçalves Assis
2016-02-21 2:34 ` Felipe Gonçalves Assis [this message]
2016-02-21 2:34 ` [PATCH v5 2/3] " Felipe Gonçalves Assis
2016-02-21 2:34 ` [PATCH v5 3/3] merge-recursive: more consistent interface Felipe Gonçalves Assis
2016-02-21 7:40 ` [PATCH v5 0/3] merge-recursive: option to disable renames Junio C Hamano
2016-02-21 15:07 ` Felipe Gonçalves Assis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456022072-5342-2-git-send-email-felipegassis@gmail.com \
--to=felipeg.assis@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=felipegassis@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.