From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: [WIP PATCH 08/10] More test scripts
Date: Mon, 21 Mar 2011 12:31:02 -0600 [thread overview]
Message-ID: <1300732264-9638-9-git-send-email-newren@gmail.com> (raw)
In-Reply-To: <1300732264-9638-1-git-send-email-newren@gmail.com>
---
t/temp10.sh | 41 +++++++++++++++++++++++++++++++++
t/temp11.sh | 41 +++++++++++++++++++++++++++++++++
t/temp50.sh | 38 ++++++++++++++++++++++++++++++
t/temp9.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 193 insertions(+), 0 deletions(-)
create mode 100755 t/temp10.sh
create mode 100755 t/temp11.sh
create mode 100755 t/temp50.sh
create mode 100755 t/temp9.sh
diff --git a/t/temp10.sh b/t/temp10.sh
new file mode 100755
index 0000000..100c74f
--- /dev/null
+++ b/t/temp10.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='merge+diff issue: rename/add vs. copy/modify'
+
+. ./test-lib.sh
+
+# Testcase setup:
+# Commit A: new file: a
+# Commit B: modify a slightly
+# Commit C: rename a->b, add completely different a
+#
+# We should be able to merge B & C cleanly
+
+test_expect_success 'setup modify + rename/add(source) merge' '
+ 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 &&
+ echo something completely different >a &&
+ git add a &&
+ git commit -m C
+'
+
+test_expect_success 'no conflict merging B & C' '
+ git checkout B^0 &&
+
+ git merge -s recursive C^0 &&
+
+ test $(git rev-parse B:a) = $(git rev-parse b) &&
+ test $(git rev-parse C:a) = $(git rev-parse a)
+'
+
+test_done
diff --git a/t/temp11.sh b/t/temp11.sh
new file mode 100755
index 0000000..1d8fb9a
--- /dev/null
+++ b/t/temp11.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='merge+diff issue: rename/add vs. copy/modify, v2'
+
+. ./test-lib.sh
+
+# Testcase setup:
+# Commit A: new file: a
+# Commit B: rename a->b
+# Commit C: rename a->c, add completely different a
+#
+# Merging of B & C should NOT be clean; there's a rename/rename conflict
+
+test_expect_success 'setup modify + rename/add(source) merge' '
+ 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 &&
+ git mv a b &&
+ git commit -m B &&
+
+ git checkout -b C A &&
+ git mv a c &&
+ echo something completely different >a &&
+ git add a &&
+ git commit -m C
+'
+
+test_expect_success 'detect conflict merging B & C' '
+ git checkout B^0 &&
+
+ test_must_fail git merge -s recursive C^0 &&
+
+ test -f a &&
+ test -f b &&
+ test -f c
+'
+
+test_done
diff --git a/t/temp50.sh b/t/temp50.sh
new file mode 100755
index 0000000..5baebec
--- /dev/null
+++ b/t/temp50.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description="Rename/rename conflict doesn't leave files in place for user"
+
+. ./test-lib.sh
+
+test_expect_success 'setup rename/rename (1to2) conflict' '
+ echo stuff >a &&
+ git add a &&
+ test_tick &&
+ git commit -m base &&
+ git tag base &&
+
+ git checkout -b one base &&
+ git mv a b &&
+ test_tick &&
+ git commit -m one &&
+
+ git checkout -b two base &&
+ git mv a c &&
+ test_tick &&
+ git commit -m two
+'
+
+test_expect_success 'merge has correct working tree contents' '
+ git checkout two^0 &&
+
+ test_must_fail git merge -s recursive one^0 &&
+
+ test 3 -eq $(git ls-files -s | wc -l) &&
+ test 3 -eq $(git ls-files -u | wc -l) &&
+ test 0 -eq $(git ls-files -o | wc -l) &&
+
+ test -f b &&
+ test -f c
+'
+
+test_done
diff --git a/t/temp9.sh b/t/temp9.sh
new file mode 100755
index 0000000..3936461
--- /dev/null
+++ b/t/temp9.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+test_description='recursive merge corner case: rename/rename + criss-cross merge + reintroduce file with name of rename source but different contents'
+
+. ./test-lib.sh
+
+#
+# Standard setup:
+#
+# B D
+# o---o
+# / \ / \
+# A o X ? F
+# \ / \ /
+# o---o
+# C E
+#
+# Commit A: new file: a
+# Commit B: rename a->b
+# Commit C: rename a->c, add different a
+# Commit D: merge B&C, keeping a&b&c, modifying a at the beginning
+# Commit E: merge B&C, keeping a&b&c, modifying a at the end
+#
+# Now, when we merge commits D & E, there should be no conflict...
+
+test_expect_success 'setup rename/rename + criss-cross + new file' '
+ printf "lots\nof\nwords\nand\ncontent\n" >a &&
+ git add a &&
+ git commit -m A &&
+ git tag A &&
+
+ git checkout -b B A &&
+ git mv a b &&
+ git commit -m B &&
+
+ git checkout -b C A &&
+ git mv a c &&
+ printf "2\n3\n4\n5\n6\n7\n" >a &&
+ git add a &&
+ git commit -m C &&
+
+ git checkout B^0 &&
+ exit 1
+ test_must_fail git merge C &&
+ mv a old_a &&
+ echo 1 >a &&
+ cat old_a >>a &&
+ rm old_a &&
+ git add -u &&
+ git commit -m D &&
+ git tag D &&
+
+ git checkout C^0 &&
+ test_must_fail git merge B &&
+ echo 6 >> a &&
+ git add -u &&
+ git commit -m E &&
+ git tag E
+'
+
+test_expect_success 'no conflict merging D & E' '
+ git checkout D^0 &&
+
+ git merge -s recursive E^0 &&
+
+ test 3 -eq $(git ls-files -s | wc -l) &&
+ test 0 -eq $(git ls-files -u | wc -l) &&
+ test 0 -eq $(git ls-files -o | wc -l) &&
+
+ test 6 -eq $(wc -l < a)
+'
+
+test_done
--
1.7.4
next prev parent reply other threads:[~2011-03-21 18:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 18:30 [WIP PATCH 00/10] Work-in-progress merge-recursive work Elijah Newren
2011-03-21 18:30 ` [WIP PATCH 01/10] merge-recursive: Remove redundant check for removing rename source Elijah Newren
2011-03-21 18:30 ` [WIP PATCH 02/10] Reminder to fix o->call_depth handling in conflict_rename_rename_1to2 Elijah Newren
2011-03-21 18:30 ` [WIP PATCH 03/10] A bunch of fixes and FIXMEs Elijah Newren
2011-03-21 18:30 ` [WIP PATCH 04/10] Correct a comment Elijah Newren
2011-03-21 18:30 ` [WIP PATCH 05/10] merge-recursive: Fix sorting order and directory change assumptions Elijah Newren
2011-03-21 18:31 ` [WIP PATCH 06/10] Add a comment pointing out a bug Elijah Newren
2011-03-21 18:31 ` [WIP PATCH 07/10] Good testcases Elijah Newren
2011-03-21 18:31 ` Elijah Newren [this message]
2011-03-21 18:31 ` [WIP PATCH 09/10] Tests and fixes associated with rename/rename conflicts Elijah Newren
2011-03-21 18:31 ` [WIP PATCH 10/10] Add new testcase (temp14) showing how undetected renames can cause or spuriously avoid merge conflicts 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=1300732264-9638-9-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).