Commit 9d7ac675d06dab2e000ad32f9248631af0191f85

nulltoken 2012-08-21T11:45:16

tree entry: rename git_tree_entry_attributes() into git_tree_entry_filemode()

diff --git a/include/git2/tree.h b/include/git2/tree.h
index 9b61e7d..e526141 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -143,9 +143,9 @@ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(git_tree *tree, const gi
  * Get the UNIX file attributes of a tree entry
  *
  * @param entry a tree entry
- * @return attributes as an integer
+ * @return filemode as an integer
  */
-GIT_EXTERN(unsigned int) git_tree_entry_attributes(const git_tree_entry *entry);
+GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry);
 
 /**
  * Get the filename of a tree entry
diff --git a/src/checkout.c b/src/checkout.c
index 252d9c4..ac54039 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -88,7 +88,7 @@ static int blob_contents_to_file(git_repository *repo, git_buf *fnbuf,
 
 	/* Allow overriding of file mode */
 	if (!file_mode)
-		file_mode = git_tree_entry_attributes(entry);
+		file_mode = git_tree_entry_filemode(entry);
 
 	if ((retcode = git_futils_mkpath2file(git_buf_cstr(fnbuf), data->opts->dir_mode)) < 0)
 		goto bctf_cleanup;
@@ -111,7 +111,7 @@ static int checkout_walker(const char *path, const git_tree_entry *entry, void *
 {
 	int retcode = 0;
 	tree_walk_data *data = (tree_walk_data*)payload;
-	int attr = git_tree_entry_attributes(entry);
+	int attr = git_tree_entry_filemode(entry);
 	git_buf fnbuf = GIT_BUF_INIT;
 	git_buf_join_n(&fnbuf, '/', 3,
 						git_repository_workdir(data->repo),
diff --git a/src/notes.c b/src/notes.c
index b592a2c..81e4e50 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -33,7 +33,7 @@ static int find_subtree_in_current_level(
 		if (!git__ishex(git_tree_entry_name(entry)))
 			continue;
 
-		if (S_ISDIR(git_tree_entry_attributes(entry))
+		if (S_ISDIR(git_tree_entry_filemode(entry))
 			&& strlen(git_tree_entry_name(entry)) == 2 
 			&& !strncmp(git_tree_entry_name(entry), annotated_object_sha + fanout, 2))
 			return git_tree_lookup(out, repo, git_tree_entry_id(entry));
diff --git a/src/tree.c b/src/tree.c
index 315269d..83aa303 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -185,9 +185,9 @@ const git_oid *git_tree_id(git_tree *c)
 	return git_object_id((git_object *)c);
 }
 
-unsigned int git_tree_entry_attributes(const git_tree_entry *entry)
+git_filemode_t git_tree_entry_filemode(const git_tree_entry *entry)
 {
-	return entry->attr;
+	return (git_filemode_t)entry->attr;
 }
 
 const char *git_tree_entry_name(const git_tree_entry *entry)
diff --git a/tests-clar/object/tree/attributes.c b/tests-clar/object/tree/attributes.c
index cee72f1..054f671 100644
--- a/tests-clar/object/tree/attributes.c
+++ b/tests-clar/object/tree/attributes.c
@@ -35,7 +35,7 @@ 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_tree_entry_attributes(entry));
+		git_tree_entry_filemode(entry));
 
 	git_tree_free(tree);
 	git_repository_free(repo);
@@ -64,7 +64,7 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
 
 	cl_assert_equal_i(
 		GIT_FILEMODE_BLOB,
-		git_tree_entry_attributes(entry));
+		git_tree_entry_filemode(entry));
 	
 	cl_git_pass(git_treebuilder_write(&tid, repo, builder));
 	git_treebuilder_free(builder);
@@ -74,7 +74,7 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
 	entry = git_tree_entry_byname(tree, "normalized.txt");
 	cl_assert_equal_i(
 		GIT_FILEMODE_BLOB,
-		git_tree_entry_attributes(entry));
+		git_tree_entry_filemode(entry));
 
 	git_tree_free(tree);
 	cl_git_sandbox_cleanup();
@@ -98,7 +98,7 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
 	entry = git_treebuilder_get(builder, "old_mode.txt");
 	cl_assert_equal_i(
 		GIT_FILEMODE_BLOB,
-		git_tree_entry_attributes(entry));
+		git_tree_entry_filemode(entry));
 
 	cl_git_pass(git_treebuilder_write(&tid2, repo, builder));
 	git_treebuilder_free(builder);
@@ -108,7 +108,7 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
 	entry = git_tree_entry_byname(tree, "old_mode.txt");
 	cl_assert_equal_i(
 		GIT_FILEMODE_BLOB,
-		git_tree_entry_attributes(entry));
+		git_tree_entry_filemode(entry));
 
 	git_tree_free(tree);
 	cl_git_sandbox_cleanup();