2 #include "clar_libgit2.h"
4 #include "git2/revert.h"
5 #include "../merge/merge_helpers.h"
7 #define TEST_REPO_PATH "revert-rename.git"
9 static git_repository
*repo
;
11 /* Fixture setup and teardown */
12 void test_revert_rename__initialize(void)
14 repo
= cl_git_sandbox_init(TEST_REPO_PATH
);
17 void test_revert_rename__cleanup(void)
19 cl_git_sandbox_cleanup();
22 /* Attempt a revert when there is a file rename AND change of file mode,
23 * but the file contents remain the same. Check that the file mode doesn't
24 * change following the revert.
26 void test_revert_rename__automerge(void)
28 git_commit
*head_commit
, *revert_commit
;
31 git_reference
*head_ref
;
33 struct merge_index_entry merge_index_entries
[] = {
34 { 0100644, "f0f64c618e1646d2948a456ed7c4bcfad5536d68", 0, "goodmode" }};
36 cl_git_pass(git_repository_head(&head_ref
, repo
));
37 cl_git_pass(git_reference_peel((git_object
**)&head_commit
, head_ref
, GIT_OBJECT_COMMIT
));
39 cl_git_pass(git_oid_fromstr(&revert_oid
, "7b4d7c3789b3581973c04087cb774c3c3576de2f"));
40 cl_git_pass(git_commit_lookup(&revert_commit
, repo
, &revert_oid
));
42 cl_git_pass(git_revert_commit(&index
, repo
, revert_commit
, head_commit
, 0, NULL
));
43 cl_assert(merge_test_index(index
, merge_index_entries
, 1));
45 git_commit_free(revert_commit
);
46 git_commit_free(head_commit
);
47 git_index_free(index
);
48 git_reference_free(head_ref
);