summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-10-01 16:12:15 -0700
committerRussell Belfer <rb@github.com>2013-10-03 10:44:13 -0700
commit219d3457324e8c2652e3462cedaf648912b40281 (patch)
tree4dcd3bd4aa22d5a9827fbc87c52546ce2a2cd7a1 /src/refdb_fs.c
parent2fe54afa2a8f87d03d2d550dcde7718f27e40967 (diff)
downloadlibgit2-219d3457324e8c2652e3462cedaf648912b40281.tar.gz
Initial iconv hookup for precomposed unicode
This hooks up git_path_direach and git_path_dirload so that they will take a flag indicating if directory entry names should be tested and converted from decomposed unicode to precomposed form. This code will only come into play on the Apple platform and even then, only when certain types of filesystems are used. This involved adding a flag to these functions which involved changing a lot of places in the code. This was an opportunity to do a bit of code cleanup here and there, for example, getting rid of the git_futils_cleanupdir_r function in favor of a simple flag to git_futils_rmdir_r to not remove the top level entry. That ended up adding depth tracking during rmdir_r which led to a safety check for infinite directory recursion. Yay. This hasn't actually been tested on the Mac filesystems where the issue occurs. I still need to get test environment for that.
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 715b311a4..afe1a2a42 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -56,6 +56,8 @@ typedef struct refdb_fs_backend {
git_sortedcache *refcache;
int peeling_mode;
+ git_iterator_flag_t iterator_flags;
+ uint32_t direach_flags;
} refdb_fs_backend;
static int packref_cmp(const void *a_, const void *b_)
@@ -269,7 +271,8 @@ static int _dirent_loose_load(void *data, git_buf *full_path)
return 0;
if (git_path_isdir(full_path->ptr))
- return git_path_direach(full_path, _dirent_loose_load, backend);
+ return git_path_direach(
+ full_path, backend->direach_flags, _dirent_loose_load, backend);
file_path = full_path->ptr + strlen(backend->path);
@@ -295,7 +298,8 @@ static int packed_loadloose(refdb_fs_backend *backend)
* This will overwrite any old packed entries with their
* updated loose versions
*/
- error = git_path_direach(&refs_path, _dirent_loose_load, backend);
+ error = git_path_direach(
+ &refs_path, backend->direach_flags, _dirent_loose_load, backend);
git_buf_free(&refs_path);
@@ -458,23 +462,17 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
{
- int error = 0, t;
+ int error = 0;
git_buf path = GIT_BUF_INIT;
- git_iterator_flag_t flags = 0;
git_iterator *fsit = NULL;
const git_index_entry *entry = NULL;
if (!backend->path) /* do nothing if no path for loose refs */
return 0;
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t)
- flags |= GIT_ITERATOR_IGNORE_CASE;
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t)
- flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
-
if ((error = git_buf_printf(&path, "%s/refs", backend->path)) < 0 ||
(error = git_iterator_for_filesystem(
- &fsit, git_buf_cstr(&path), flags, NULL, NULL)) < 0) {
+ &fsit, path.ptr, backend->iterator_flags, NULL, NULL)) < 0) {
git_buf_free(&path);
return error;
}
@@ -1077,6 +1075,7 @@ int git_refdb_backend_fs(
git_refdb_backend **backend_out,
git_repository *repository)
{
+ int t = 0;
git_buf path = GIT_BUF_INIT;
refdb_fs_backend *backend;
@@ -1098,6 +1097,15 @@ int git_refdb_backend_fs(
git_buf_free(&path);
+ if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) {
+ backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
+ backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
+ }
+ if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) {
+ backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
+ backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
+ }
+
backend->parent.exists = &refdb_fs_backend__exists;
backend->parent.lookup = &refdb_fs_backend__lookup;
backend->parent.iterator = &refdb_fs_backend__iterator;