Skip to content

Commit

Permalink
Horrible fix for libgit2#3173.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber authored and pks-t committed Feb 18, 2016
1 parent 98fda81 commit 4ca7f19
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 53 deletions.
5 changes: 3 additions & 2 deletions src/checkout.c
Expand Up @@ -2521,7 +2521,8 @@ int git_checkout_iterator(

if (data.opts.baseline_index) {
if ((error = git_iterator_for_index(
&baseline, data.opts.baseline_index, &baseline_opts)) < 0)
&baseline, git_index_owner(data.opts.baseline_index),
data.opts.baseline_index, &baseline_opts)) < 0)
goto cleanup;
} else {
if ((error = git_iterator_for_tree(
Expand Down Expand Up @@ -2633,7 +2634,7 @@ int git_checkout_index(
return error;
GIT_REFCOUNT_INC(index);

if (!(error = git_iterator_for_index(&index_i, index, NULL)))
if (!(error = git_iterator_for_index(&index_i, repo, index, NULL)))
error = git_checkout_iterator(index_i, index, opts);

if (owned)
Expand Down
8 changes: 4 additions & 4 deletions src/diff.c
Expand Up @@ -1371,7 +1371,7 @@ int git_diff_tree_to_index(

DIFF_FROM_ITERATORS(
git_iterator_for_tree(&a, old_tree, &a_opts), iflag,
git_iterator_for_index(&b, index, &b_opts), iflag
git_iterator_for_index(&b, repo, index, &b_opts), iflag
);

/* if index is in case-insensitive order, re-sort deltas to match */
Expand All @@ -1395,7 +1395,7 @@ int git_diff_index_to_workdir(
return error;

DIFF_FROM_ITERATORS(
git_iterator_for_index(&a, index, &a_opts),
git_iterator_for_index(&a, repo, index, &a_opts),
GIT_ITERATOR_INCLUDE_CONFLICTS,

git_iterator_for_workdir(&b, repo, index, NULL, &b_opts),
Expand Down Expand Up @@ -1472,8 +1472,8 @@ int git_diff_index_to_index(
assert(diff && old_index && new_index);

DIFF_FROM_ITERATORS(
git_iterator_for_index(&a, old_index, &a_opts), GIT_ITERATOR_DONT_IGNORE_CASE,
git_iterator_for_index(&b, new_index, &b_opts), GIT_ITERATOR_DONT_IGNORE_CASE
git_iterator_for_index(&a, repo, old_index, &a_opts), GIT_ITERATOR_DONT_IGNORE_CASE,
git_iterator_for_index(&b, repo, new_index, &b_opts), GIT_ITERATOR_DONT_IGNORE_CASE
);

/* if index is in case-insensitive order, re-sort deltas to match */
Expand Down
4 changes: 2 additions & 2 deletions src/index.c
Expand Up @@ -2907,8 +2907,8 @@ int git_index_read_index(

opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;

if ((error = git_iterator_for_index(&index_iterator, index, &opts)) < 0 ||
(error = git_iterator_for_index(&new_iterator, (git_index *)new_index, &opts)) < 0)
if ((error = git_iterator_for_index(&index_iterator, git_index_owner(index), index, &opts)) < 0 ||
(error = git_iterator_for_index(&new_iterator, git_index_owner(new_index), (git_index *)new_index, &opts)) < 0)
goto done;

if (((error = git_iterator_current(&old_entry, index_iterator)) < 0 &&
Expand Down
5 changes: 3 additions & 2 deletions src/iterator.c
Expand Up @@ -1080,6 +1080,7 @@ static void index_iterator__free(git_iterator *self)

int git_iterator_for_index(
git_iterator **iter,
git_repository *repo,
git_index *index,
git_iterator_options *options)
{
Expand All @@ -1093,7 +1094,7 @@ int git_iterator_for_index(
}
ii->index = index;

ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index));
ITERATOR_BASE_INIT(ii, index, INDEX, repo);

if ((error = iterator__update_ignore_case((git_iterator *)ii, options ? options->flags : 0)) < 0) {
git_iterator_free((git_iterator *)ii);
Expand Down Expand Up @@ -2071,7 +2072,7 @@ int git_iterator_advance_over_with_status(

if (!error)
continue;

else if (error == GIT_ENOTFOUND) {
/* we entered this directory only hoping to find child matches to
* our pathlist (eg, this is `foo` and we had a pathlist entry for
Expand Down
1 change: 1 addition & 0 deletions src/iterator.h
Expand Up @@ -95,6 +95,7 @@ extern int git_iterator_for_tree(
*/
extern int git_iterator_for_index(
git_iterator **out,
git_repository *repo,
git_index *index,
git_iterator_options *options);

Expand Down
14 changes: 7 additions & 7 deletions src/merge.c
Expand Up @@ -2083,9 +2083,9 @@ static int iterator_for_annotated_commit(
opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;

if (commit == NULL) {
error = git_iterator_for_nothing(out, &opts);
error = git_iterator_for_nothing(out, &opts);
} else if (commit->type == GIT_ANNOTATED_COMMIT_VIRTUAL) {
error = git_iterator_for_index(out, commit->index, &opts);
error = git_iterator_for_index(out, git_index_owner(commit->index), commit->index, &opts);
} else {
if (!commit->tree &&
(error = git_commit_tree(&commit->tree, commit->commit)) < 0)
Expand Down Expand Up @@ -2427,7 +2427,7 @@ static int write_merge_msg(
assert(repo && heads);

entries = git__calloc(heads_len, sizeof(struct merge_msg_entry));
GITERR_CHECK_ALLOC(entries);
GITERR_CHECK_ALLOC(entries);

if (git_vector_init(&matching, heads_len, NULL) < 0) {
git__free(entries);
Expand Down Expand Up @@ -2481,7 +2481,7 @@ static int write_merge_msg(

if (matching.length)
sep =',';

if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tag)) < 0 ||
(error = merge_msg_write_tags(&file, &matching, sep)) < 0)
goto cleanup;
Expand Down Expand Up @@ -2682,8 +2682,8 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
iter_opts.pathlist.strings = (char **)staged_paths.contents;
iter_opts.pathlist.count = staged_paths.length;

if ((error = git_iterator_for_index(&iter_repo, index_repo, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 ||
if ((error = git_iterator_for_index(&iter_repo, repo, index_repo, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&iter_new, repo, index_new, &iter_opts)) < 0 ||
(error = git_diff__from_iterators(&index_diff_list, repo, iter_repo, iter_new, &opts)) < 0)
goto done;

Expand Down Expand Up @@ -2759,7 +2759,7 @@ int git_merge__check_result(git_repository *repo, git_index *index_new)

if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
(error = git_iterator_for_tree(&iter_head, head_tree, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&iter_new, repo, index_new, &iter_opts)) < 0 ||
(error = git_diff__from_iterators(&merged_list, repo, iter_head, iter_new, &opts)) < 0)
goto done;

Expand Down
3 changes: 1 addition & 2 deletions src/pathspec.c
Expand Up @@ -550,7 +550,7 @@ int git_pathspec_match_index(

iter_opts.flags = pathspec_match_iter_flags(flags);

if (!(error = git_iterator_for_index(&iter, index, &iter_opts))) {
if (!(error = git_iterator_for_index(&iter, git_index_owner(index), index, &iter_opts))) {
error = pathspec_match_from_iterator(out, iter, flags, ps);
git_iterator_free(iter);
}
Expand Down Expand Up @@ -718,4 +718,3 @@ const char * git_pathspec_match_list_failed_entry(

return entry ? *entry : NULL;
}

8 changes: 4 additions & 4 deletions src/stash.c
Expand Up @@ -685,8 +685,8 @@ static int merge_indexes(
iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;

if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&theirs, theirs_index, &iter_opts)) < 0)
(error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&theirs, repo, theirs_index, &iter_opts)) < 0)
goto done;

error = git_merge__iterators(out, repo, ancestor, ours, theirs, NULL);
Expand All @@ -712,7 +712,7 @@ static int merge_index_and_tree(
iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;

if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 ||
(error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
(error = git_iterator_for_tree(&theirs, theirs_tree, &iter_opts)) < 0)
goto done;

Expand All @@ -728,7 +728,7 @@ static int merge_index_and_tree(
static void normalize_apply_options(
git_stash_apply_options *opts,
const git_stash_apply_options *given_apply_opts)
{
{
if (given_apply_opts != NULL) {
memcpy(opts, given_apply_opts, sizeof(git_stash_apply_options));
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/submodule.c
Expand Up @@ -327,7 +327,7 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
const git_index_entry *entry;
git_buf name = GIT_BUF_INIT;

if ((error = git_iterator_for_index(&i, idx, NULL)) < 0)
if ((error = git_iterator_for_index(&i, git_index_owner(idx), idx, NULL)) < 0)
return error;

while (!(error = git_iterator_advance(&entry, i))) {
Expand Down Expand Up @@ -1037,7 +1037,7 @@ static int submodule_repo_create(

/**
* Repodir: path to the sub-repo. sub-repo goes in:
* <repo-dir>/modules/<name>/ with a gitlink in the
* <repo-dir>/modules/<name>/ with a gitlink in the
* sub-repo workdir directory to that repository.
*/
error = git_buf_join3(
Expand Down Expand Up @@ -1154,7 +1154,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
clone_options.repository_cb_payload = sm;

/*
* Do not perform checkout as part of clone, instead we
* Do not perform checkout as part of clone, instead we
* will checkout the specific commit manually.
*/
clone_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;
Expand Down
4 changes: 2 additions & 2 deletions tests/diff/iterator.c
Expand Up @@ -380,7 +380,7 @@ static void index_iterator_test(
iter_opts.start = start;
iter_opts.end = end;

cl_git_pass(git_iterator_for_index(&i, index, &iter_opts));
cl_git_pass(git_iterator_for_index(&i, repo, index, &iter_opts));

while (!(error = git_iterator_advance(&entry, i))) {
cl_assert(entry);
Expand Down Expand Up @@ -974,7 +974,7 @@ static void check_index_range(
i_opts.start = start;
i_opts.end = end;

cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
cl_git_pass(git_iterator_for_index(&i, repo, index, &i_opts));

cl_assert(git_iterator_ignore_case(i) == ignore_case);

Expand Down

0 comments on commit 4ca7f19

Please sign in to comment.