diff options
author | Edward Thomson <ethomson@github.com> | 2016-02-15 17:16:00 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-02-15 19:27:06 +0000 |
commit | f28bae0c380467409515ffd25247f3204dcc4019 (patch) | |
tree | 437cafaa9d8afc0b59c6b63bd5d5cf068fc52fe7 /tests/rebase | |
parent | 5a296ad07ea5536a0ac2f17921f2839612d838d3 (diff) | |
download | libgit2-f28bae0c380467409515ffd25247f3204dcc4019.tar.gz |
rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
Diffstat (limited to 'tests/rebase')
-rw-r--r-- | tests/rebase/inmemory.c | 10 | ||||
-rw-r--r-- | tests/rebase/iterator.c | 20 |
2 files changed, 24 insertions, 6 deletions
diff --git a/tests/rebase/inmemory.c b/tests/rebase/inmemory.c index c7942d6af..d5d89c719 100644 --- a/tests/rebase/inmemory.c +++ b/tests/rebase/inmemory.c @@ -54,7 +54,7 @@ void test_rebase_inmemory__can_resolve_conflicts(void) git_status_list *status_list; git_oid pick_id, commit_id, expected_commit_id; git_signature *signature; - git_index *repo_index; + git_index *rebase_index, *repo_index; git_index_entry resolution = {{0}}; git_rebase_options opts = GIT_REBASE_OPTIONS_INIT; @@ -86,7 +86,8 @@ void test_rebase_inmemory__can_resolve_conflicts(void) cl_assert_equal_i(0, git_status_list_entrycount(status_list)); /* but that the index returned from rebase does have conflicts */ - cl_assert(git_index_has_conflicts(rebase_operation->index)); + cl_git_pass(git_rebase_inmemory_index(&rebase_index, rebase)); + cl_assert(git_index_has_conflicts(rebase_index)); cl_git_fail_with(GIT_EUNMERGED, git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL)); @@ -94,8 +95,8 @@ void test_rebase_inmemory__can_resolve_conflicts(void) resolution.path = "asparagus.txt"; resolution.mode = GIT_FILEMODE_BLOB; git_oid_fromstr(&resolution.id, "414dfc71ead79c07acd4ea47fecf91f289afc4b9"); - cl_git_pass(git_index_conflict_remove(rebase_operation->index, "asparagus.txt")); - cl_git_pass(git_index_add(rebase_operation->index, &resolution)); + cl_git_pass(git_index_conflict_remove(rebase_index, "asparagus.txt")); + cl_git_pass(git_index_add(rebase_index, &resolution)); /* and finally create a commit for the resolved rebase operation */ cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL)); @@ -110,5 +111,6 @@ void test_rebase_inmemory__can_resolve_conflicts(void) git_reference_free(branch_ref); git_reference_free(upstream_ref); git_index_free(repo_index); + git_index_free(rebase_index); git_rebase_free(rebase); } diff --git a/tests/rebase/iterator.c b/tests/rebase/iterator.c index e761d39d3..db57b0a83 100644 --- a/tests/rebase/iterator.c +++ b/tests/rebase/iterator.c @@ -13,7 +13,8 @@ void test_rebase_iterator__initialize(void) { repo = cl_git_sandbox_init("rebase"); cl_git_pass(git_repository_index(&_index, repo)); - cl_git_pass(git_signature_now(&signature, "Rebaser", "rebaser@rebaser.rb")); + cl_git_pass(git_signature_new(&signature, "Rebaser", + "rebaser@rebaser.rb", 1405694510, 0)); } void test_rebase_iterator__cleanup(void) @@ -53,7 +54,7 @@ void test_iterator(bool inmemory) git_reference *branch_ref, *upstream_ref; git_annotated_commit *branch_head, *upstream_head; git_rebase_operation *rebase_operation; - git_oid commit_id; + git_oid commit_id, expected_id; int error; opts.inmemory = inmemory; @@ -77,16 +78,25 @@ void test_iterator(bool inmemory) NULL, NULL)); test_operations(rebase, 0); + git_oid_fromstr(&expected_id, "776e4c48922799f903f03f5f6e51da8b01e4cce0"); + cl_assert_equal_oid(&expected_id, &commit_id); + cl_git_pass(git_rebase_next(&rebase_operation, rebase)); cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL)); test_operations(rebase, 1); + git_oid_fromstr(&expected_id, "ba1f9b4fd5cf8151f7818be2111cc0869f1eb95a"); + cl_assert_equal_oid(&expected_id, &commit_id); + cl_git_pass(git_rebase_next(&rebase_operation, rebase)); cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL)); test_operations(rebase, 2); + git_oid_fromstr(&expected_id, "948b12fe18b84f756223a61bece4c307787cd5d4"); + cl_assert_equal_oid(&expected_id, &commit_id); + if (!inmemory) { git_rebase_free(rebase); cl_git_pass(git_rebase_open(&rebase, repo, NULL)); @@ -97,11 +107,17 @@ void test_iterator(bool inmemory) NULL, NULL)); test_operations(rebase, 3); + git_oid_fromstr(&expected_id, "d9d5d59d72c9968687f9462578d79878cd80e781"); + cl_assert_equal_oid(&expected_id, &commit_id); + cl_git_pass(git_rebase_next(&rebase_operation, rebase)); cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL)); test_operations(rebase, 4); + git_oid_fromstr(&expected_id, "9cf383c0a125d89e742c5dec58ed277dd07588b3"); + cl_assert_equal_oid(&expected_id, &commit_id); + cl_git_fail(error = git_rebase_next(&rebase_operation, rebase)); cl_assert_equal_i(GIT_ITEROVER, error); test_operations(rebase, 4); |