Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-07-17 19:59:01 +0400
committerEdward Thomson <ethomson@microsoft.com>2014-10-27 05:59:16 +0300
commit443d5674fe3f2edd4cb51c7657e7ad5063275bff (patch)
tree3531fd9f481183b492a2dfa3c69da6e413e4edb3 /tests/rebase
parent950a70915930342d18286c6d6350929662a978e2 (diff)
git_rebase_next: write conflicts nicely during rebase
Diffstat (limited to 'tests/rebase')
-rw-r--r--tests/rebase/merge.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index e44fdd3f6..506c411ed 100644
--- a/tests/rebase/merge.c
+++ b/tests/rebase/merge.c
@@ -57,3 +57,62 @@ void test_rebase_merge__next(void)
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
}
+
+void test_rebase_merge__next_with_conflicts(void)
+{
+ git_reference *branch_ref, *upstream_ref;
+ git_merge_head *branch_head, *upstream_head;
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_status_list *status_list;
+ const git_status_entry *status_entry;
+
+ const char *expected_merge =
+"ASPARAGUS SOUP.\n"
+"\n"
+"<<<<<<< master\n"
+"TAKE FOUR LARGE BUNCHES of asparagus, scrape it nicely, cut off one inch\n"
+"OF THE TOPS, and lay them in water, chop the stalks and put them on the\n"
+"FIRE WITH A PIECE OF BACON, a large onion cut up, and pepper and salt;\n"
+"ADD TWO QUARTS OF WATER, boil them till the stalks are quite soft, then\n"
+"PULP THEM THROUGH A SIEVE, and strain the water to it, which must be put\n"
+"=======\n"
+"Take four large bunches of asparagus, scrape it nicely, CUT OFF ONE INCH\n"
+"of the tops, and lay them in water, chop the stalks and PUT THEM ON THE\n"
+"fire with a piece of bacon, a large onion cut up, and pepper and salt;\n"
+"add two quarts of water, boil them till the stalks are quite soft, then\n"
+"pulp them through a sieve, and strain the water to it, which must be put\n"
+">>>>>>> Conflicting modification 1 to asparagus\n"
+"back in the pot; put into it a chicken cut up, with the tops of\n"
+"asparagus which had been laid by, boil it until these last articles are\n"
+"sufficiently done, thicken with flour, butter and milk, and serve it up.\n";
+
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+ cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus"));
+ cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+ cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
+ cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
+
+ cl_git_pass(git_rebase(repo, branch_head, upstream_head, NULL, signature, NULL));
+
+ cl_git_pass(git_rebase_next(repo, &checkout_opts));
+
+ cl_assert_equal_file("33f915f9e4dbd9f4b24430e48731a59b45b15500\n", 41, "rebase/.git/rebase-merge/current");
+ cl_assert_equal_file("1\n", 2, "rebase/.git/rebase-merge/msgnum");
+
+ cl_git_pass(git_status_list_new(&status_list, repo, NULL));
+ cl_assert_equal_i(1, git_status_list_entrycount(status_list));
+ cl_assert(status_entry = git_status_byindex(status_list, 0));
+
+ cl_assert_equal_s("asparagus.txt", status_entry->head_to_index->new_file.path);
+
+ cl_assert_equal_file(expected_merge, strlen(expected_merge), "rebase/asparagus.txt");
+
+ git_status_list_free(status_list);
+ git_merge_head_free(branch_head);
+ git_merge_head_free(upstream_head);
+ git_reference_free(branch_ref);
+ git_reference_free(upstream_ref);
+}
+