git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 2/2] merge-ort: add t/t4310-merge-tree-ort.sh

From
Christian Couder <christian.couder@gmail.com>
Date
Jan 5, 2022, 16:33 UTC
Message-ID
<20220105163324.73369-3-chriscool@tuxfamily.org>
In-Reply-To
<20220105163324.73369-1-chriscool@tuxfamily.org>

This adds a few tests for the new merge-tree-ort command. They have been copy-pasted from t4300-merge-tree.sh, and then the expected output has been adjusted.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t4310-merge-tree-ort.sh | 162 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 162 insertions(+)
 create mode 100755 t/t4310-merge-tree-ort.sh
diff --git a/t/t4310-merge-tree-ort.sh b/t/t4310-merge-tree-ort.sh
new file mode 100755
index 0000000000..9a54508e82
--- /dev/null
+++ b/t/t4310-merge-tree-ort.sh
@@ -0,0 +1,162 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Will Palmer
+# Copyright (c) 2021 Christian Couder
+#
+
+test_description='git merge-tree-ort'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit "initial" "initial-file" "initial"
+'
+
+test_expect_success 'file add A, !B' '
+	git reset --hard initial &&
+	test_commit "add-a-not-b" "ONE" "AAA" &&
+	git merge-tree-ort initial initial add-a-not-b >actual &&
+	cat >expected <<EXPECTED &&
+result tree: ee38e20a5c0e1698539ac99d55616079a04fce26
+clean: 1
+diff with branch1:
+:000000 100644 0000000 43d5a8e A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..43d5a8e
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1 @@
++AAA
+diff with branch2:
+diff with base:
+:000000 100644 0000000 43d5a8e A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..43d5a8e
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1 @@
++AAA
+EXPECTED
+
+	test_cmp expected actual
+'
+
+test_expect_success 'file add !A, B' '
+	git reset --hard initial &&
+	test_commit "add-not-a-b" "ONE" "AAA" &&
+	git merge-tree-ort initial add-not-a-b initial >actual &&
+	cat >expected <<EXPECTED &&
+result tree: ee38e20a5c0e1698539ac99d55616079a04fce26
+clean: 1
+diff with branch1:
+diff with branch2:
+:000000 100644 0000000 43d5a8e A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..43d5a8e
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1 @@
++AAA
+diff with base:
+:000000 100644 0000000 43d5a8e A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..43d5a8e
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1 @@
++AAA
+EXPECTED
+
+	test_cmp expected actual
+'
+
+test_expect_success 'file add A, B (same)' '
+	git reset --hard initial &&
+	test_commit "add-a-b-same-A" "ONE" "AAA" &&
+	git reset --hard initial &&
+	test_commit "add-a-b-same-B" "ONE" "AAA" &&
+	git merge-tree-ort initial add-a-b-same-A add-a-b-same-B >actual &&
+	cat >expected <<EXPECTED &&
+result tree: ee38e20a5c0e1698539ac99d55616079a04fce26
+clean: 1
+diff with branch1:
+diff with branch2:
+diff with base:
+:000000 100644 0000000 43d5a8e A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..43d5a8e
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1 @@
++AAA
+EXPECTED
+
+	test_cmp expected actual
+'
+
+test_expect_success 'file add A, B (different)' '
+	git reset --hard initial &&
+	test_commit "add-a-b-diff-A" "ONE" "AAA" &&
+	git reset --hard initial &&
+	test_commit "add-a-b-diff-B" "ONE" "BBB" &&
+	git merge-tree-ort initial add-a-b-diff-A add-a-b-diff-B >actual &&
+	cat >expected <<EXPECTED &&
+result tree: 3aa938e8cc8be73c81cbaf629ea55a16e7c39319
+clean: 0
+diff with branch1:
+:100644 100644 43d5a8e 1e462bc M	ONE
+
+diff --git a/ONE b/ONE
+index 43d5a8e..1e462bc 100644
+--- a/ONE
++++ b/ONE
+@@ -1 +1,5 @@
++<<<<<<< add-a-b-diff-A
+ AAA
++=======
++BBB
++>>>>>>> add-a-b-diff-B
+diff with branch2:
+:100644 100644 ba62923 1e462bc M	ONE
+
+diff --git a/ONE b/ONE
+index ba62923..1e462bc 100644
+--- a/ONE
++++ b/ONE
+@@ -1 +1,5 @@
++<<<<<<< add-a-b-diff-A
++AAA
++=======
+ BBB
++>>>>>>> add-a-b-diff-B
+diff with base:
+:000000 100644 0000000 1e462bc A	ONE
+
+diff --git a/ONE b/ONE
+new file mode 100644
+index 0000000..1e462bc
+--- /dev/null
++++ b/ONE
+@@ -0,0 +1,5 @@
++<<<<<<< add-a-b-diff-A
++AAA
++=======
++BBB
++>>>>>>> add-a-b-diff-B
+EXPECTED
+
+	test_cmp expected actual
+'
+
+test_done
-- 
2.34.1.433.g7bc349372a.dirty
Previous: Elijah NewrenNext: Elijah Newren
Message 4 of 28 in “Introduce new merge-tree-ort command”
  1. 0/2 Introduce new merge-tree-ort commandChristian Couder, Jan 5, 2022
  2. 1/2 merge-ort: add new merge-tree-ort commandChristian Couder, Jan 5, 2022
  3. Elijah NewrenJan 5, 2022
  4. 2/2 merge-ort: add t/t4310-merge-tree-ort.shChristian Couder, Jan 5, 2022
  5. Elijah NewrenJan 5, 2022
  6. Elijah NewrenJan 5, 2022
  7. Elijah NewrenJan 5, 2022
  8. Christian CouderJan 7, 2022
  9. Elijah NewrenJan 7, 2022
  10. Johannes SchindelinJan 10, 2022
  11. Junio C HamanoJan 10, 2022
  12. Johannes SchindelinJan 11, 2022
  13. Ævar Arnfjörð BjarmasonJan 11, 2022
  14. Elijah NewrenJan 11, 2022
  15. Junio C HamanoJan 12, 2022
  16. Elijah NewrenJan 12, 2022
  17. Junio C HamanoJan 13, 2022
  18. Elijah NewrenJan 13, 2022
  19. Ævar Arnfjörð BjarmasonJan 13, 2022
  20. Junio C HamanoJan 12, 2022
  21. Ævar Arnfjörð BjarmasonJan 13, 2022
  22. Elijah NewrenJan 10, 2022
  23. Elijah NewrenJan 11, 2022
  24. Johannes SchindelinFeb 22, 2022
  25. Johannes SchindelinJan 11, 2022
  26. Elijah NewrenJan 12, 2022
  27. Johannes SchindelinFeb 22, 2022
  28. Johannes SchindelinJan 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.