Signed-off-by: Karl Wiberg <[email protected]>

---

 t/t1502-float-conflict-1.sh |   38 ++++++++++++++++++++++++++++++++++++++
 t/t1503-float-conflict-2.sh |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100755 t/t1502-float-conflict-1.sh
 create mode 100755 t/t1503-float-conflict-2.sh


diff --git a/t/t1502-float-conflict-1.sh b/t/t1502-float-conflict-1.sh
new file mode 100755
index 0000000..7356d27
--- /dev/null
+++ b/t/t1502-float-conflict-1.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+test_description='Test that "stg float" can handle conflicts'
+. ./test-lib.sh
+
+test_expect_success 'Test setup' '
+    stg init &&
+    echo expected.txt >> .git/info/exclude &&
+    echo first line > foo.txt &&
+    git add foo.txt &&
+    git commit -m p0 &&
+    echo foo >> foo.txt &&
+    git add foo.txt &&
+    git commit -m p1 &&
+    echo foo2 >> foo.txt &&
+    git add foo.txt &&
+    git commit -m p2 &&
+    stg uncommit -n 3
+'
+
+cat > expected.txt <<EOF
+first line
+<<<<<<< current
+=======
+foo
+foo2
+>>>>>>> patched
+EOF
+
+test_expect_success 'Float a patch, causing a conflict with the next patch' '
+    conflict stg float p1 &&
+    test "$(echo $(stg series))" = "+ p0 > p2 - p1" &&
+    test "$(stg id p2)" = "$(git rev-list HEAD~0 -n 1)" &&
+    test "$(stg id p0)" = "$(git rev-list HEAD~1 -n 1)" &&
+    test "$(stg status)" = "C foo.txt" &&
+    test_cmp foo.txt expected.txt
+'
+
+test_done
diff --git a/t/t1503-float-conflict-2.sh b/t/t1503-float-conflict-2.sh
new file mode 100755
index 0000000..661b711
--- /dev/null
+++ b/t/t1503-float-conflict-2.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+test_description='Test that "stg float" can handle conflicts'
+. ./test-lib.sh
+
+test_expect_success 'Test setup' '
+    stg init &&
+    echo expected.txt >> .git/info/exclude &&
+    echo first line > foo.txt &&
+    git add foo.txt &&
+    git commit -m p0 &&
+    echo foo >> foo.txt &&
+    git add foo.txt &&
+    git commit -m p1 &&
+    echo bar >> bar.txt &&
+    git add bar.txt &&
+    git commit -m p2 &&
+    echo foo2 >> foo.txt &&
+    git add foo.txt &&
+    git commit -m p3 &&
+    stg uncommit -n 4
+'
+
+cat > expected.txt <<EOF
+first line
+<<<<<<< current
+=======
+foo
+foo2
+>>>>>>> patched
+EOF
+
+test_expect_failure 'Float a patch, causing a conflict two patches down' '
+    conflict stg float p1 &&
+    test "$(echo $(stg series))" = "+ p0 + p2 > p3 - p1" &&
+    test "$(stg id p3)" = "$(git rev-list HEAD~0 -n 1)" &&
+    test "$(stg id p2)" = "$(git rev-list HEAD~1 -n 1)" &&
+    test "$(stg id p0)" = "$(git rev-list HEAD~2 -n 1)" &&
+    test "$(stg status)" = "C foo.txt" &&
+    test_cmp foo.txt expected.txt
+'
+
+test_done


_______________________________________________
stgit-users mailing list
[email protected]
https://mail.gna.org/listinfo/stgit-users

Reply via email to