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:
authorRussell Belfer <rb@github.com>2013-10-02 03:12:15 +0400
committerRussell Belfer <rb@github.com>2013-10-03 21:44:13 +0400
commit219d3457324e8c2652e3462cedaf648912b40281 (patch)
tree4dcd3bd4aa22d5a9827fbc87c52546ce2a2cd7a1 /src/iterator.c
parent2fe54afa2a8f87d03d2d550dcde7718f27e40967 (diff)
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/iterator.c')
-rw-r--r--src/iterator.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/iterator.c b/src/iterator.c
index 946790449..ea6b45e88 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -893,6 +893,7 @@ struct fs_iterator {
git_index_entry entry;
git_buf path;
size_t root_len;
+ uint32_t dirload_flags;
int depth;
int (*enter_dir_cb)(fs_iterator *self);
@@ -986,10 +987,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi)
GITERR_CHECK_ALLOC(ff);
error = git_path_dirload_with_stat(
- fi->path.ptr, fi->root_len,
- (iterator__ignore_case(fi) ? GIT_PATH_DIRLOAD_IGNORE_CASE : 0) |
- (iterator__flag(fi, PRECOMPOSE_UNICODE) ?
- GIT_PATH_DIRLOAD_PRECOMPOSE_UNICODE : 0),
+ fi->path.ptr, fi->root_len, fi->dirload_flags,
fi->base.start, fi->base.end, &ff->entries);
if (error < 0) {
@@ -1210,6 +1208,11 @@ static int fs_iterator__initialize(
}
fi->root_len = fi->path.size;
+ fi->dirload_flags =
+ (iterator__ignore_case(fi) ? GIT_PATH_DIR_IGNORE_CASE : 0) |
+ (iterator__flag(fi, PRECOMPOSE_UNICODE) ?
+ GIT_PATH_DIR_PRECOMPOSE_UNICODE : 0);
+
if ((error = fs_iterator__expand_dir(fi)) < 0) {
if (error == GIT_ENOTFOUND || error == GIT_ITEROVER) {
giterr_clear();
@@ -1332,7 +1335,7 @@ int git_iterator_for_workdir_ext(
const char *start,
const char *end)
{
- int error;
+ int error, precompose = 0;
workdir_iterator *wi;
if (!repo_workdir) {
@@ -1360,13 +1363,10 @@ int git_iterator_for_workdir_ext(
}
/* try to look up precompose and set flag if appropriate */
- {
- int precompose = 0;
- if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0)
- giterr_clear();
- else if (precompose)
- wi->fi.base.flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
- }
+ if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0)
+ giterr_clear();
+ else if (precompose)
+ wi->fi.base.flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
return fs_iterator__initialize(out, &wi->fi, repo_workdir);
}