Commit 34a51428a121800509c2bea94137a17802e37982

Edward Thomson 2015-11-09T11:55:26

merge tests: add complex recursive example

diff --git a/tests/merge/trees/recursive.c b/tests/merge/trees/recursive.c
index abca017..1e5f613 100644
--- a/tests/merge/trees/recursive.c
+++ b/tests/merge/trees/recursive.c
@@ -269,3 +269,31 @@ void test_merge_trees_recursive__conflict(void)
 	git_index_free(index);
 }
 
+/* 
+ * Branch G-1 and G-2 have three common ancestors (815b5a1, ad2ace9, 483065d).
+ * The merge-base of the first two has two common ancestors (723181f, a34e5a1)
+ * which themselves have two common ancestors (8f35f30, 3a3f5a6), which
+ * finally has a common ancestor of 7c7bf85.  This virtual merge base will
+ * be computed and merged with 483065d which also has a common ancestor of
+ * 7c7bf85.
+ */
+void test_merge_trees_recursive__oh_so_many_levels_of_recursion(void)
+{
+	git_index *index;
+	git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
+
+	struct merge_index_entry merge_index_entries[] = {
+		{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
+		{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
+		{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
+		{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
+		{ 0100644, "7c7e08f9559d9e1551b91e1cf68f1d0066109add", 0, "oyster.txt" },
+		{ 0100644, "898d12687fb35be271c27c795a6b32c8b51da79e", 0, "veal.txt" },
+	};
+
+	cl_git_pass(merge_commits_from_branches(&index, repo, "branchG-1", "branchG-2", &opts));
+
+	cl_assert(merge_test_index(index, merge_index_entries, 6));
+
+	git_index_free(index);
+}
diff --git a/tests/resources/merge-recursive/.gitted/HEAD b/tests/resources/merge-recursive/.gitted/HEAD
index 77e3574..d7cef11 100644
--- a/tests/resources/merge-recursive/.gitted/HEAD
+++ b/tests/resources/merge-recursive/.gitted/HEAD
@@ -1 +1 @@
-ref: refs/heads/branchB-1
+ref: refs/heads/branchG-2
diff --git a/tests/resources/merge-recursive/.gitted/index b/tests/resources/merge-recursive/.gitted/index
index 1e47851..571cfd0 100644
Binary files a/tests/resources/merge-recursive/.gitted/index and b/tests/resources/merge-recursive/.gitted/index differ
diff --git a/tests/resources/merge-recursive/.gitted/objects/34/8f16ffaeb73f319a75cec5b16a0a47d2d5e27c b/tests/resources/merge-recursive/.gitted/objects/34/8f16ffaeb73f319a75cec5b16a0a47d2d5e27c
new file mode 100644
index 0000000..bd1b1f6
Binary files /dev/null and b/tests/resources/merge-recursive/.gitted/objects/34/8f16ffaeb73f319a75cec5b16a0a47d2d5e27c differ
diff --git a/tests/resources/merge-recursive/.gitted/objects/48/3065df53c0f4a02cdc6b2910b05d388fc17ffb b/tests/resources/merge-recursive/.gitted/objects/48/3065df53c0f4a02cdc6b2910b05d388fc17ffb
new file mode 100644
index 0000000..298251b
Binary files /dev/null and b/tests/resources/merge-recursive/.gitted/objects/48/3065df53c0f4a02cdc6b2910b05d388fc17ffb differ
diff --git a/tests/resources/merge-recursive/.gitted/objects/c4/83ca4bb087174af5cb51d7caa9c09fe4a28ccb b/tests/resources/merge-recursive/.gitted/objects/c4/83ca4bb087174af5cb51d7caa9c09fe4a28ccb
new file mode 100644
index 0000000..643a982
--- /dev/null
+++ b/tests/resources/merge-recursive/.gitted/objects/c4/83ca4bb087174af5cb51d7caa9c09fe4a28ccb
@@ -0,0 +1 @@
+xPKN@cS̮d#!+v\ d[E}E\`۱lɼ-0.cW5熱5Қ\sX(V#$V;g1Hy±ڂP!HmzXb-X \^)\+15WP!g`JHw~Uy㘷<'b^m9oӮ~y\-o˽AdC2}C3g3	GCq;zl<{
\ No newline at end of file
diff --git a/tests/resources/merge-recursive/.gitted/objects/d7/1c24b3b113fd1d1909998c5bfe33b86a65ee03 b/tests/resources/merge-recursive/.gitted/objects/d7/1c24b3b113fd1d1909998c5bfe33b86a65ee03
new file mode 100644
index 0000000..6672008
Binary files /dev/null and b/tests/resources/merge-recursive/.gitted/objects/d7/1c24b3b113fd1d1909998c5bfe33b86a65ee03 differ
diff --git a/tests/resources/merge-recursive/.gitted/refs/heads/branchG-1 b/tests/resources/merge-recursive/.gitted/refs/heads/branchG-1
new file mode 100644
index 0000000..af51143
--- /dev/null
+++ b/tests/resources/merge-recursive/.gitted/refs/heads/branchG-1
@@ -0,0 +1 @@
+c483ca4bb087174af5cb51d7caa9c09fe4a28ccb
diff --git a/tests/resources/merge-recursive/.gitted/refs/heads/branchG-2 b/tests/resources/merge-recursive/.gitted/refs/heads/branchG-2
new file mode 100644
index 0000000..24177a2
--- /dev/null
+++ b/tests/resources/merge-recursive/.gitted/refs/heads/branchG-2
@@ -0,0 +1 @@
+d71c24b3b113fd1d1909998c5bfe33b86a65ee03
diff --git a/tests/resources/merge-recursive/asparagus.txt b/tests/resources/merge-recursive/asparagus.txt
index f516580..ffb36e5 100644
--- a/tests/resources/merge-recursive/asparagus.txt
+++ b/tests/resources/merge-recursive/asparagus.txt
@@ -1,4 +1,4 @@
-ASPARAGUS SOUP!
+ASPARAGUS SOUP.
 
 Take four large bunches of asparagus, scrape it nicely, cut off one inch
 of the tops, and lay them in water, chop the stalks and put them on the
diff --git a/tests/resources/merge-recursive/oyster.txt b/tests/resources/merge-recursive/oyster.txt
index 68af1fc..7c7e08f 100644
--- a/tests/resources/merge-recursive/oyster.txt
+++ b/tests/resources/merge-recursive/oyster.txt
@@ -1,4 +1,4 @@
-OYSTER SOUP.
+OYSTER SOUP!
 
 Wash and drain two quarts of oysters, put them on with three quarts of
 water, three onions chopped up, two or three slices of lean ham, pepper
diff --git a/tests/resources/merge-recursive/veal.txt b/tests/resources/merge-recursive/veal.txt
index 94d2c01..898d126 100644
--- a/tests/resources/merge-recursive/veal.txt
+++ b/tests/resources/merge-recursive/veal.txt
@@ -1,10 +1,10 @@
-VEAL SOUP!
+VEAL SOUP.
 
-Put into a pot three quarts of water, three onions cut small, one
+PUT INTO A POT THREE QUARTS OF WATER, 3 onions cut small, ONE
 spoonful of black pepper pounded, and two of salt, with two or three
 slices of lean ham; let it boil steadily two hours; skim it
 occasionally, then put into it a shin of veal, let it boil two hours
-longer. take out the slices of ham, and skim off the grease if any
+longer; take out the slices of ham, and skim off the grease if any
 should rise, take a gill of good cream, mix with it two table-spoonsful
 of flour very nicely, and the yelks of two eggs beaten well, strain this
 mixture, and add some chopped parsley; pour some soup on by degrees,
@@ -16,3 +16,5 @@ in, first taking off their skins, by letting them stand a few minutes in
 hot water, when they may be easily peeled. When made in this way you
 must thicken it with the flour only. Any part of the veal may be used,
 but the shin or knuckle is the nicest.
+
+This is a mighty fine recipe!