Skip to content

Commit 516f751

Browse files
author
Colin Stolley
committed
Add test for revert+rename bug.
1 parent 479a38b commit 516f751

File tree

9 files changed

+60
-0
lines changed

9 files changed

+60
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = true
5+
logallrefupdates = true
209 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
P pack-4363774fb90141e8aa7a326ace0566366114e869.pack
2+
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# pack-refs with: peeled fully-peeled sorted
2+
ecef6a85173b6f446873a13f7b5a7b54a85cd912 refs/heads/master
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ecef6a85173b6f446873a13f7b5a7b54a85cd912

tests/revert/rename.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "clar.h"
2+
#include "clar_libgit2.h"
3+
4+
#include "git2/revert.h"
5+
#include "../merge/merge_helpers.h"
6+
7+
#define TEST_REPO_PATH "revert-rename.git"
8+
9+
static git_repository *repo;
10+
11+
/* Fixture setup and teardown */
12+
void test_revert_rename__initialize(void)
13+
{
14+
repo = cl_git_sandbox_init(TEST_REPO_PATH);
15+
}
16+
17+
void test_revert_rename__cleanup(void)
18+
{
19+
cl_git_sandbox_cleanup();
20+
}
21+
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.
25+
*/
26+
void test_revert_rename__automerge(void)
27+
{
28+
git_commit *head_commit, *revert_commit;
29+
git_oid revert_oid;
30+
git_index *index;
31+
git_reference *head_ref;
32+
33+
struct merge_index_entry merge_index_entries[] = {
34+
{ 0100644, "f0f64c618e1646d2948a456ed7c4bcfad5536d68", 0, "goodmode" }};
35+
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));
38+
39+
cl_git_pass(git_oid_fromstr(&revert_oid, "7b4d7c3789b3581973c04087cb774c3c3576de2f"));
40+
cl_git_pass(git_commit_lookup(&revert_commit, repo, &revert_oid));
41+
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));
44+
45+
git_commit_free(revert_commit);
46+
git_commit_free(head_commit);
47+
git_index_free(index);
48+
git_reference_free(head_ref);
49+
}

0 commit comments

Comments
 (0)