diff options
author | Edward Thomson <ethomson@microsoft.com> | 2014-07-15 18:23:10 +0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2014-10-27 05:59:14 +0300 |
commit | 950a70915930342d18286c6d6350929662a978e2 (patch) | |
tree | ad7ce6126e0f1098cb4903605716f5b65ec74083 /tests/rebase | |
parent | 4fe84d624b42a1ef1b9b392483ddc43064b1180e (diff) |
Introduce git_rebase_next
`git_rebase_next` will apply the next patch (or cherry-pick)
operation, leaving the results checked out in the index / working
directory so that consumers can resolve any conflicts, as appropriate.
Diffstat (limited to 'tests/rebase')
-rw-r--r-- | tests/rebase/merge.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c new file mode 100644 index 000000000..e44fdd3f6 --- /dev/null +++ b/tests/rebase/merge.c @@ -0,0 +1,59 @@ +#include "clar_libgit2.h" +#include "git2/rebase.h" +#include "posix.h" + +#include <fcntl.h> + +static git_repository *repo; +static git_signature *signature; + +// Fixture setup and teardown +void test_rebase_merge__initialize(void) +{ + repo = cl_git_sandbox_init("rebase"); +} + +void test_rebase_merge__cleanup(void) +{ + cl_git_sandbox_cleanup(); +} + +void test_rebase_merge__next(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; + git_oid file1_id; + + checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; + + cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef")); + 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("da9c51a23d02d931a486f45ad18cda05cf5d2b94\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("beef.txt", status_entry->head_to_index->new_file.path); + + git_oid_fromstr(&file1_id, "8d95ea62e621f1d38d230d9e7d206e41096d76af"); + cl_assert_equal_oid(&file1_id, &status_entry->head_to_index->new_file.id); + + 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); +} |