summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Stolley <ccstolley@github.com>2021-09-09 15:08:36 -0500
committerColin Stolley <ccstolley@github.com>2021-09-15 17:09:17 -0500
commit516f7519f0b0b38cabc6c98ff1428b46b1f20b3e (patch)
treec2448a6d6cc0ce543bfafa293877f76820dfd424
parent479a38bf153f13966a423124994e4ed91561e595 (diff)
downloadlibgit2-516f7519f0b0b38cabc6c98ff1428b46b1f20b3e.tar.gz
Add test for revert+rename bug.
-rw-r--r--tests/resources/revert-rename.git/HEAD1
-rw-r--r--tests/resources/revert-rename.git/config5
-rw-r--r--tests/resources/revert-rename.git/indexbin0 -> 209 bytes
-rw-r--r--tests/resources/revert-rename.git/objects/info/packs2
-rw-r--r--tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.idxbin0 -> 1296 bytes
-rw-r--r--tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.packbin0 -> 783 bytes
-rw-r--r--tests/resources/revert-rename.git/packed-refs2
-rw-r--r--tests/resources/revert-rename.git/refs/heads/master1
-rw-r--r--tests/revert/rename.c49
9 files changed, 60 insertions, 0 deletions
diff --git a/tests/resources/revert-rename.git/HEAD b/tests/resources/revert-rename.git/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/tests/resources/revert-rename.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/revert-rename.git/config b/tests/resources/revert-rename.git/config
new file mode 100644
index 000000000..a4ef456cb
--- /dev/null
+++ b/tests/resources/revert-rename.git/config
@@ -0,0 +1,5 @@
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = true
+ logallrefupdates = true
diff --git a/tests/resources/revert-rename.git/index b/tests/resources/revert-rename.git/index
new file mode 100644
index 000000000..232325dfb
--- /dev/null
+++ b/tests/resources/revert-rename.git/index
Binary files differ
diff --git a/tests/resources/revert-rename.git/objects/info/packs b/tests/resources/revert-rename.git/objects/info/packs
new file mode 100644
index 000000000..5d971426e
--- /dev/null
+++ b/tests/resources/revert-rename.git/objects/info/packs
@@ -0,0 +1,2 @@
+P pack-4363774fb90141e8aa7a326ace0566366114e869.pack
+
diff --git a/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.idx b/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.idx
new file mode 100644
index 000000000..3fb48ea94
--- /dev/null
+++ b/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.idx
Binary files differ
diff --git a/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.pack b/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.pack
new file mode 100644
index 000000000..e078ec2aa
--- /dev/null
+++ b/tests/resources/revert-rename.git/objects/pack/pack-4363774fb90141e8aa7a326ace0566366114e869.pack
Binary files differ
diff --git a/tests/resources/revert-rename.git/packed-refs b/tests/resources/revert-rename.git/packed-refs
new file mode 100644
index 000000000..e062909d4
--- /dev/null
+++ b/tests/resources/revert-rename.git/packed-refs
@@ -0,0 +1,2 @@
+# pack-refs with: peeled fully-peeled sorted
+ecef6a85173b6f446873a13f7b5a7b54a85cd912 refs/heads/master
diff --git a/tests/resources/revert-rename.git/refs/heads/master b/tests/resources/revert-rename.git/refs/heads/master
new file mode 100644
index 000000000..3771102fb
--- /dev/null
+++ b/tests/resources/revert-rename.git/refs/heads/master
@@ -0,0 +1 @@
+ecef6a85173b6f446873a13f7b5a7b54a85cd912
diff --git a/tests/revert/rename.c b/tests/revert/rename.c
new file mode 100644
index 000000000..0d713c60f
--- /dev/null
+++ b/tests/revert/rename.c
@@ -0,0 +1,49 @@
+#include "clar.h"
+#include "clar_libgit2.h"
+
+#include "git2/revert.h"
+#include "../merge/merge_helpers.h"
+
+#define TEST_REPO_PATH "revert-rename.git"
+
+static git_repository *repo;
+
+/* Fixture setup and teardown */
+void test_revert_rename__initialize(void)
+{
+ repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_revert_rename__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+/* Attempt a revert when there is a file rename AND change of file mode,
+ * but the file contents remain the same. Check that the file mode doesn't
+ * change following the revert.
+ */
+void test_revert_rename__automerge(void)
+{
+ git_commit *head_commit, *revert_commit;
+ git_oid revert_oid;
+ git_index *index;
+ git_reference *head_ref;
+
+ struct merge_index_entry merge_index_entries[] = {
+ { 0100644, "f0f64c618e1646d2948a456ed7c4bcfad5536d68", 0, "goodmode" }};
+
+ cl_git_pass(git_repository_head(&head_ref, repo));
+ cl_git_pass(git_reference_peel((git_object **)&head_commit, head_ref, GIT_OBJECT_COMMIT));
+
+ cl_git_pass(git_oid_fromstr(&revert_oid, "7b4d7c3789b3581973c04087cb774c3c3576de2f"));
+ cl_git_pass(git_commit_lookup(&revert_commit, repo, &revert_oid));
+
+ cl_git_pass(git_revert_commit(&index, repo, revert_commit, head_commit, 0, NULL));
+ cl_assert(merge_test_index(index, merge_index_entries, 1));
+
+ git_commit_free(revert_commit);
+ git_commit_free(head_commit);
+ git_index_free(index);
+ git_reference_free(head_ref);
+}