From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: [RFC/PATCH 05/18] Add testcase for --index-only merges needing the recursive strategy
Date: Thu, 7 Apr 2016 23:58:33 -0700 [thread overview]
Message-ID: <1460098726-5958-6-git-send-email-newren@gmail.com> (raw)
In-Reply-To: <1460098726-5958-1-git-send-email-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
t/t6043-merge-index-only.sh | 170 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 170 insertions(+)
create mode 100755 t/t6043-merge-index-only.sh
diff --git a/t/t6043-merge-index-only.sh b/t/t6043-merge-index-only.sh
new file mode 100755
index 0000000..b8b22ab
--- /dev/null
+++ b/t/t6043-merge-index-only.sh
@@ -0,0 +1,170 @@
+#!/bin/sh
+
+test_description="index-only merges"
+
+. ./test-lib.sh
+
+# Testcase setup for rename/modify:
+# Commit A: new file: a
+# Commit B: modify a slightly
+# Commit C: rename a->b
+# We should be able to merge B & C cleanly
+
+test_expect_success 'setup rename/modify merge' '
+ git init &&
+
+ printf "1\n2\n3\n4\n5\n6\n7\n" >a &&
+ git add a &&
+ git commit -m A &&
+ git tag A &&
+
+ git checkout -b B A &&
+ echo 8 >>a &&
+ git add a &&
+ git commit -m B &&
+
+ git checkout -b C A &&
+ git mv a b &&
+ git commit -m C
+'
+
+test_expect_failure '--index-only with rename/modify works in non-bare-clone' '
+ git checkout B^0 &&
+
+ git merge --index-only -s recursive C^0 &&
+
+ echo "Making sure the working copy was not updated" &&
+ test ! -f b &&
+ test -f a &&
+ test $(git rev-parse B:a) = $(git hash-object a) &&
+
+ echo "Making sure the index was updated" &&
+ test 1 -eq $(git ls-files -s | wc -l) &&
+ test $(git rev-parse B:a) = $(git rev-parse :b)
+'
+
+test_expect_failure '--index-only with rename/modify works in a bare clone' '
+ git clone --bare . bare.clone &&
+ (cd bare.clone &&
+
+ git update-ref --no-deref HEAD B &&
+ git read-tree HEAD &&
+
+ git merge --index-only -s recursive C^0 &&
+
+ echo "Making sure the working copy was not updated" &&
+ test ! -f b &&
+ test ! -f a &&
+
+ echo "Making sure the index was updated" &&
+ test 1 -eq $(git ls-files -s | wc -l) &&
+ test $(git rev-parse B:a) = $(git rev-parse :b)
+ )
+'
+
+# Testcase requiring recursion to handle:
+#
+# L1 L2
+# o---o--o
+# / \ / \
+# B o X o C
+# \ / \ /
+# o---o--o
+# R1 R2
+#
+# B : 1..20
+# L1: 1..3 a..c 4..20
+# R1: 1..13n..p14..20
+# L2: 1..3 a..i 4..13 n..p 14..20
+# R2: 1..3 a..c 4..13 n..v 14..20
+# C: 1..3 a..i 4..13 n..v 14..20
+# needs 'recursive' strategy to get correct solution; 'resolve' would fail
+#
+
+test_expect_success 'setup single-file criss-cross resolvable with recursive strategy' '
+ git reset --hard &&
+ git rm -rf . &&
+ git clean -fdqx &&
+ rm -rf .git &&
+ git init &&
+
+ seq 1 20 >contents &&
+ git add contents &&
+ test_tick && git commit -m initial &&
+
+ git branch R1 &&
+ git checkout -b L1 &&
+ seq 1 3 >contents &&
+ seq 1 3 | tr 1-3 a-c >>contents &&
+ seq 4 20 >>contents &&
+ git add contents &&
+ test_tick && git commit -m L1 &&
+
+ git checkout R1 &&
+ seq 1 13 >contents &&
+ seq 1 3 | tr 1-3 n-p >>contents &&
+ seq 14 20 >>contents &&
+ git add contents &&
+ test_tick && git commit -m R1 &&
+
+ git checkout -b L2 L1^0 &&
+ test_tick && git merge R1 &&
+ seq 1 3 >contents &&
+ seq 1 9 | tr 1-9 a-i >>contents &&
+ seq 4 13 >>contents &&
+ seq 1 3 | tr 1-3 n-p >>contents &&
+ seq 14 20 >>contents &&
+ git add contents &&
+ test_tick && git commit -m L2 &&
+
+ git checkout -b R2 R1^0 &&
+ test_tick && git merge L1 &&
+ seq 1 3 >contents &&
+ seq 1 3 | tr 1-3 a-c >>contents &&
+ seq 4 13 >>contents &&
+ seq 1 9 | tr 1-9 n-v >>contents &&
+ seq 14 20 >>contents &&
+ git add contents &&
+ test_tick && git commit -m R2 &&
+
+ seq 1 3 >answer &&
+ seq 1 9 | tr 1-9 a-i >>answer &&
+ seq 4 13 >>answer &&
+ seq 1 9 | tr 1-9 n-v >>answer &&
+ seq 14 20 >>answer &&
+ git tag answer $(git hash-object -w answer) &&
+ rm -f answer
+'
+
+test_expect_failure 'recursive --index-only in non-bare repo' '
+ git reset --hard &&
+ git checkout L2^0 &&
+
+ git merge --index-only -s recursive R2^0 &&
+
+ test 1 = $(git ls-files -s | wc -l) &&
+ test 0 = $(git ls-files -u | wc -l) &&
+ test 0 = $(git ls-files -o | wc -l) &&
+
+ test $(git rev-parse :contents) = $(git rev-parse answer) &&
+ test $(git rev-parse L2:contents) = $(git hash-object contents)
+'
+
+test_expect_failure 'recursive --index-only in bare repo' '
+ git clone --bare . bare.clone &&
+ (cd bare.clone &&
+
+ git update-ref --no-deref HEAD L2 &&
+ git read-tree HEAD &&
+
+ git merge --index-only -s recursive R2^0 &&
+
+ test 1 = $(git ls-files -s | wc -l) &&
+ test 0 = $(git ls-files -u | wc -l) &&
+
+ test $(git rev-parse :contents) = $(git rev-parse answer) &&
+ test ! -f contents
+ )
+'
+
+test_done
--
2.8.0.18.gc685494
next prev parent reply other threads:[~2016-04-08 6:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 6:58 [RFC/PATCH 00/18] Add --index-only option to git merge Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 01/18] Remove duplicate code Elijah Newren
2016-04-08 23:34 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 02/18] Avoid checking working copy when creating a virtual merge base Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 03/18] Document weird bug in octopus merges via testcases Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 04/18] merge-octopus: Abort if index not clean Elijah Newren
2016-04-08 19:31 ` Junio C Hamano
2016-04-08 6:58 ` Elijah Newren [this message]
2016-04-08 19:37 ` [RFC/PATCH 05/18] Add testcase for --index-only merges needing the recursive strategy Junio C Hamano
2016-04-08 20:14 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 06/18] Add testcase for --index-only merges needing an ff update Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 07/18] Add testcase for --index-only merges with the resolve strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 08/18] Add testcase for --index-only merges with the octopus strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 09/18] Add testcase for --index-only merges with the ours strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 10/18] Add testcase for --index-only merges with the subtree strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 11/18] merge: Add a new --index-only option, not yet implemented Elijah Newren
2016-04-08 22:33 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 12/18] Add --index-only support for recursive merges Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 13/18] Add --index-only support with read_tree_trivial merges, kind of Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 14/18] Add --index-only support for ff_only merges Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 15/18] merge: Pass --index-only along to external merge strategy programs Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 16/18] git-merge-one-file.sh: support --index-only option Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 17/18] git-merge-resolve.sh: " Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 18/18] git-merge-octopus.sh: " Elijah Newren
2016-04-08 13:01 ` [RFC/PATCH 00/18] Add --index-only option to git merge Michael J Gruber
2016-04-09 3:09 ` Elijah Newren
2016-04-08 18:08 ` Junio C Hamano
2016-04-09 2:35 ` Elijah Newren
2016-04-09 4:44 ` Junio C Hamano
2016-04-10 5:33 ` Elijah Newren
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=1460098726-5958-6-git-send-email-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).