[WIP PATCH 08/10] More test scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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

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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]