Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2012-12-07 18:16:41 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2012-12-07 19:59:18 +0400
commitf1c75b94a17a2835f4166c11efe1cb4084bf5388 (patch)
tree0507db030d492149b8a40bf9c14ab83ee8fcc211 /tests-clar/object/tree/attributes.c
parentfac43c54a6f02d3dbedd11ec228d4cb606a52bff (diff)
tree: relax the filemode parser
There are many different broken filemodes in the wild so we need to protect against them and give something useful up the chain. Don't fail when reading a tree from the ODB but normalize the mode as best we can. As 664 is no longer a mode that we consider to be valid and gets normalized to 644, we can stop accepting it in the treebuilder. The library won't expose it to the user, so any invalid modes are a bug.
Diffstat (limited to 'tests-clar/object/tree/attributes.c')
-rw-r--r--tests-clar/object/tree/attributes.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/tests-clar/object/tree/attributes.c b/tests-clar/object/tree/attributes.c
index 054f67137..b5319d30e 100644
--- a/tests-clar/object/tree/attributes.c
+++ b/tests-clar/object/tree/attributes.c
@@ -34,14 +34,14 @@ void test_object_tree_attributes__group_writable_tree_entries_created_with_an_an
entry = git_tree_entry_byname(tree, "old_mode.txt");
cl_assert_equal_i(
- GIT_FILEMODE_BLOB_GROUP_WRITABLE,
+ GIT_FILEMODE_BLOB,
git_tree_entry_filemode(entry));
git_tree_free(tree);
git_repository_free(repo);
}
-void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_tree(void)
+void test_object_tree_attributes__treebuilder_reject_invalid_filemode(void)
{
git_repository *repo;
git_treebuilder *builder;
@@ -55,28 +55,14 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
cl_git_pass(git_treebuilder_create(&builder, NULL));
- cl_git_pass(git_treebuilder_insert(
+ cl_git_fail(git_treebuilder_insert(
&entry,
builder,
"normalized.txt",
&bid,
GIT_FILEMODE_BLOB_GROUP_WRITABLE));
- cl_assert_equal_i(
- GIT_FILEMODE_BLOB,
- git_tree_entry_filemode(entry));
-
- cl_git_pass(git_treebuilder_write(&tid, repo, builder));
git_treebuilder_free(builder);
-
- cl_git_pass(git_tree_lookup(&tree, repo, &tid));
-
- entry = git_tree_entry_byname(tree, "normalized.txt");
- cl_assert_equal_i(
- GIT_FILEMODE_BLOB,
- git_tree_entry_filemode(entry));
-
- git_tree_free(tree);
cl_git_sandbox_cleanup();
}
@@ -113,3 +99,22 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
git_tree_free(tree);
cl_git_sandbox_cleanup();
}
+
+void test_object_tree_attributes__normalize_600(void)
+{
+ git_oid id;
+ git_tree *tree;
+ git_repository *repo;
+ const git_tree_entry *entry;
+
+ repo = cl_git_sandbox_init("deprecated-mode.git");
+
+ git_oid_fromstr(&id, "0810fb7818088ff5ac41ee49199b51473b1bd6c7");
+ cl_git_pass(git_tree_lookup(&tree, repo, &id));
+
+ entry = git_tree_entry_byname(tree, "ListaTeste.xml");
+ cl_assert_equal_i(entry->attr, GIT_FILEMODE_BLOB);
+
+ git_tree_free(tree);
+ cl_git_sandbox_cleanup();
+}