summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-08-24 09:47:09 +0100
committerGitHub <noreply@github.com>2018-08-24 09:47:09 +0100
commitfd7ab1d7d9db54c32bfe3664316a13ee63ec341f (patch)
tree4d8b5ec9771183efcc7f01e20e00265a0044d806
parent503af775a5c749133725dfd6bdf7569930a822b5 (diff)
parent3a1f5df87b1be025b21972a592a6d0a75cfa2bb2 (diff)
downloadlibgit2-fd7ab1d7d9db54c32bfe3664316a13ee63ec341f.tar.gz
Merge pull request #4776 from pks-t/pks/test-index-invalid-filemode
tests: verify adding index conflicts with invalid filemodes fails
-rw-r--r--tests/index/conflicts.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/index/conflicts.c b/tests/index/conflicts.c
index 367d5b5bc..27fbe2b05 100644
--- a/tests/index/conflicts.c
+++ b/tests/index/conflicts.c
@@ -91,6 +91,48 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
cl_assert(git_index_entry_stage(conflict_entry[2]) == 3);
}
+void test_index_conflicts__add_detects_invalid_filemode(void)
+{
+ git_index_entry ancestor_entry, our_entry, their_entry;
+ git_index_entry *conflict_entry[3];
+ int i;
+
+ cl_assert(git_index_entrycount(repo_index) == 8);
+
+ memset(&ancestor_entry, 0x0, sizeof(git_index_entry));
+ memset(&our_entry, 0x0, sizeof(git_index_entry));
+ memset(&their_entry, 0x0, sizeof(git_index_entry));
+
+ conflict_entry[0] = &ancestor_entry;
+ conflict_entry[1] = &our_entry;
+ conflict_entry[2] = &their_entry;
+
+ for (i = 0; i < 3; i++) {
+ ancestor_entry.path = "test-one.txt";
+ ancestor_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3);
+ git_oid_fromstr(&ancestor_entry.id, CONFLICTS_ONE_ANCESTOR_OID);
+
+ our_entry.path = "test-one.txt";
+ our_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&our_entry, 1);
+ git_oid_fromstr(&our_entry.id, CONFLICTS_ONE_OUR_OID);
+
+ their_entry.path = "test-one.txt";
+ their_entry.mode = 0100644;
+ GIT_IDXENTRY_STAGE_SET(&their_entry, 2);
+ git_oid_fromstr(&their_entry.id, CONFLICTS_ONE_THEIR_OID);
+
+ /* Corrupt the conflict entry's mode */
+ conflict_entry[i]->mode = 027431745;
+
+ cl_git_fail(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
+ }
+
+ cl_assert(git_index_entrycount(repo_index) == 8);
+}
+
+
void test_index_conflicts__add_removes_stage_zero(void)
{
git_index_entry ancestor_entry, our_entry, their_entry;