summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-03-04 16:19:38 -0800
committerVicent Martí <vicent@github.com>2013-03-04 16:19:38 -0800
commitb8daa9e0fc9669f0677105b5ecce5c67462a108e (patch)
tree9e9734e256ca95665fc0bc383586fd7bae300490 /src
parentf6d96409a84f0b4c854da830027ff26bb10e27c3 (diff)
parentcb53669e14f9a29b797d108c50d04566f82ab58f (diff)
downloadlibgit2-b8daa9e0fc9669f0677105b5ecce5c67462a108e.tar.gz
Merge pull request #1380 from phkelley/index_icase
Disable ignore_case when writing the index to a tree
Diffstat (limited to 'src')
-rw-r--r--src/index.c6
-rw-r--r--src/index.h2
-rw-r--r--src/tree.c16
3 files changed, 21 insertions, 3 deletions
diff --git a/src/index.c b/src/index.c
index eb3376c7a..4deafd77f 100644
--- a/src/index.c
+++ b/src/index.c
@@ -242,8 +242,10 @@ static unsigned int index_merge_mode(
return index_create_mode(mode);
}
-static void index_set_ignore_case(git_index *index, bool ignore_case)
+void git_index__set_ignore_case(git_index *index, bool ignore_case)
{
+ index->ignore_case = ignore_case;
+
index->entries._cmp = ignore_case ? index_icmp : index_cmp;
index->entries_cmp_path = ignore_case ? index_icmp_path : index_cmp_path;
index->entries_search = ignore_case ? index_isrch : index_srch;
@@ -372,7 +374,7 @@ int git_index_set_caps(git_index *index, unsigned int caps)
}
if (old_ignore_case != index->ignore_case) {
- index_set_ignore_case(index, index->ignore_case);
+ git_index__set_ignore_case(index, index->ignore_case);
}
return 0;
diff --git a/src/index.h b/src/index.h
index 9304b5539..2beaa6375 100644
--- a/src/index.h
+++ b/src/index.h
@@ -48,6 +48,8 @@ extern size_t git_index__prefix_position(git_index *index, const char *path);
extern int git_index_entry__cmp(const void *a, const void *b);
extern int git_index_entry__cmp_icase(const void *a, const void *b);
+extern void git_index__set_ignore_case(git_index *index, bool ignore_case);
+
extern int git_index_read_tree_match(
git_index *index, git_tree *tree, git_strarray *strspec);
diff --git a/src/tree.c b/src/tree.c
index ec57e8bb8..11123a18a 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -566,6 +566,7 @@ int git_tree__write_index(
git_oid *oid, git_index *index, git_repository *repo)
{
int ret;
+ bool old_ignore_case = false;
assert(oid && index && repo);
@@ -580,8 +581,21 @@ int git_tree__write_index(
return 0;
}
- /* The tree cache didn't help us */
+ /* The tree cache didn't help us; we'll have to write
+ * out a tree. If the index is ignore_case, we must
+ * make it case-sensitive for the duration of the tree-write
+ * operation. */
+
+ if (index->ignore_case) {
+ old_ignore_case = true;
+ git_index__set_ignore_case(index, false);
+ }
+
ret = write_tree(oid, repo, index, "", 0);
+
+ if (old_ignore_case)
+ git_index__set_ignore_case(index, true);
+
return ret < 0 ? ret : 0;
}