summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-04-18 12:33:19 +0200
committerVicent Marti <vicent@github.com>2014-04-18 12:33:19 +0200
commit28fd7206b1359b6564bad3c66382b47a8f2e3eb1 (patch)
treee0d9204bdfea2a948d94b2b14d382a697b00b6db /src/checkout.c
parent2bed3553f4595a42d9a6884edc66b991e21f881e (diff)
parent8303827226db114a1157e6173e731f316c217851 (diff)
downloadlibgit2-28fd7206b1359b6564bad3c66382b47a8f2e3eb1.tar.gz
Merge pull request #2108 from libgit2/rb/threadsafe-index-iterator
Make index iterator thread safe
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 141fc1331..0b385226b 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -277,19 +277,23 @@ static int checkout_action_wd_only(
/* check if item is tracked in the index but not in the checkout diff */
if (data->index != NULL) {
+ size_t pos;
+
+ error = git_index__find_pos(
+ &pos, data->index, wd->path, 0, GIT_INDEX_STAGE_ANY);
+
if (wd->mode != GIT_FILEMODE_TREE) {
- if (!(error = git_index_find(NULL, data->index, wd->path))) {
+ if (!error) { /* found by git_index__find_pos call */
notify = GIT_CHECKOUT_NOTIFY_DIRTY;
remove = ((data->strategy & GIT_CHECKOUT_FORCE) != 0);
} else if (error != GIT_ENOTFOUND)
return error;
else
- giterr_clear();
+ error = 0; /* git_index__find_pos does not set error msg */
} else {
/* for tree entries, we have to see if there are any index
* entries that are contained inside that tree
*/
- size_t pos = git_index__prefix_position(data->index, wd->path);
const git_index_entry *e = git_index_get_byindex(data->index, pos);
if (e != NULL && data->diff->pfxcomp(e->path, wd->path) == 0) {
@@ -653,10 +657,13 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
return diff;
}
-int checkout_conflictdata_empty(const git_vector *conflicts, size_t idx)
+int checkout_conflictdata_empty(
+ const git_vector *conflicts, size_t idx, void *payload)
{
checkout_conflictdata *conflict;
+ GIT_UNUSED(payload);
+
if ((conflict = git_vector_get(conflicts, idx)) == NULL)
return -1;
@@ -954,7 +961,8 @@ static int checkout_conflicts_coalesce_renames(
ancestor_conflict->one_to_two = 1;
}
- git_vector_remove_matching(&data->conflicts, checkout_conflictdata_empty);
+ git_vector_remove_matching(
+ &data->conflicts, checkout_conflictdata_empty, NULL);
done:
return error;