diff options
-rw-r--r-- | src/checkout.c | 5 | ||||
-rw-r--r-- | src/diff.c | 8 | ||||
-rw-r--r-- | src/index.c | 4 | ||||
-rw-r--r-- | src/iterator.c | 5 | ||||
-rw-r--r-- | src/iterator.h | 1 | ||||
-rw-r--r-- | src/merge.c | 14 | ||||
-rw-r--r-- | src/pathspec.c | 3 | ||||
-rw-r--r-- | src/stash.c | 8 | ||||
-rw-r--r-- | src/submodule.c | 6 | ||||
-rw-r--r-- | tests/diff/iterator.c | 4 | ||||
-rw-r--r-- | tests/repo/iterator.c | 50 |
11 files changed, 55 insertions, 53 deletions
diff --git a/src/checkout.c b/src/checkout.c index fd8e2c443..95ce3c9d3 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -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( @@ -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) diff --git a/src/diff.c b/src/diff.c index 67fab0763..9ac5b9250 100644 --- a/src/diff.c +++ b/src/diff.c @@ -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 */ @@ -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), @@ -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 */ diff --git a/src/index.c b/src/index.c index 081a1ea59..ac4d8eee7 100644 --- a/src/index.c +++ b/src/index.c @@ -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 && diff --git a/src/iterator.c b/src/iterator.c index ee348de6e..04aac3e01 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -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) { @@ -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); @@ -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 diff --git a/src/iterator.h b/src/iterator.h index 59f87e9de..ac17d2970 100644 --- a/src/iterator.h +++ b/src/iterator.h @@ -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); diff --git a/src/merge.c b/src/merge.c index 70c705af6..d2f92ccce 100644 --- a/src/merge.c +++ b/src/merge.c @@ -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) @@ -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); @@ -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; @@ -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; @@ -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; diff --git a/src/pathspec.c b/src/pathspec.c index 5bb69ec4b..8a93cdd50 100644 --- a/src/pathspec.c +++ b/src/pathspec.c @@ -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); } @@ -718,4 +718,3 @@ const char * git_pathspec_match_list_failed_entry( return entry ? *entry : NULL; } - diff --git a/src/stash.c b/src/stash.c index 35824659a..43a464e64 100644 --- a/src/stash.c +++ b/src/stash.c @@ -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); @@ -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; @@ -728,7 +728,7 @@ done: 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 { diff --git a/src/submodule.c b/src/submodule.c index 6ec4c53e1..3e55c5676 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -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))) { @@ -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( @@ -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; diff --git a/tests/diff/iterator.c b/tests/diff/iterator.c index eafb1b9da..8417e8ed4 100644 --- a/tests/diff/iterator.c +++ b/tests/diff/iterator.c @@ -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); @@ -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); diff --git a/tests/repo/iterator.c b/tests/repo/iterator.c index 83b824691..c18e24a4f 100644 --- a/tests/repo/iterator.c +++ b/tests/repo/iterator.c @@ -134,19 +134,19 @@ void test_repo_iterator__index(void) cl_git_pass(git_repository_index(&index, g_repo)); /* autoexpand with no tree entries for index */ - cl_git_pass(git_iterator_for_index(&i, index, NULL)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, NULL)); expect_iterator_items(i, 20, NULL, 20, NULL); git_iterator_free(i); /* auto expand with tree entries */ i_opts.flags = GIT_ITERATOR_INCLUDE_TREES; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 22, NULL, 22, NULL); git_iterator_free(i); /* no auto expand (implies trees included) */ i_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 12, NULL, 22, NULL); git_iterator_free(i); @@ -171,13 +171,13 @@ void test_repo_iterator__index_icase(void) /* autoexpand with no tree entries over range */ i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 7, NULL, 7, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 3, NULL, 3, NULL); git_iterator_free(i); @@ -186,13 +186,13 @@ void test_repo_iterator__index_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 8, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 4, NULL, 4, NULL); git_iterator_free(i); @@ -201,13 +201,13 @@ void test_repo_iterator__index_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 5, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 1, NULL, 4, NULL); git_iterator_free(i); @@ -219,13 +219,13 @@ void test_repo_iterator__index_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 13, NULL, 13, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 5, NULL, 5, NULL); git_iterator_free(i); @@ -234,13 +234,13 @@ void test_repo_iterator__index_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 14, NULL, 14, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 6, NULL, 6, NULL); git_iterator_free(i); @@ -249,13 +249,13 @@ void test_repo_iterator__index_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 9, NULL, 14, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 1, NULL, 6, NULL); git_iterator_free(i); @@ -1108,14 +1108,14 @@ void test_repo_iterator__indexfilelist(void) /* All indexfilelist iterator tests are "autoexpand with no tree entries" */ - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 8, NULL, 8, NULL); git_iterator_free(i); i_opts.start = "c"; i_opts.end = NULL; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); /* (c D e k/1 k/a L ==> 6) vs (c e k/1 k/a ==> 4) */ expect = ((default_icase) ? 6 : 4); expect_iterator_items(i, expect, NULL, expect, NULL); @@ -1124,7 +1124,7 @@ void test_repo_iterator__indexfilelist(void) i_opts.start = NULL; i_opts.end = "e"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); /* (a B c D e ==> 5) vs (B D L/1 a c e ==> 6) */ expect = ((default_icase) ? 5 : 6); expect_iterator_items(i, expect, NULL, expect, NULL); @@ -1166,7 +1166,7 @@ void test_repo_iterator__indexfilelist_2(void) /* (c D e k/1 k/a ==> 5) vs (c e k/1 ==> 3) */ expect = default_icase ? 5 : 3; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, expect, NULL, expect, NULL); git_iterator_free(i); @@ -1208,7 +1208,7 @@ void test_repo_iterator__indexfilelist_3(void) /* (c D e k/1 k/a k/B k/c k/D) vs (c e k/1 k/B k/D) */ expect = default_icase ? 8 : 5; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, expect, NULL, expect, NULL); git_iterator_free(i); @@ -1250,7 +1250,7 @@ void test_repo_iterator__indexfilelist_4(void) /* (c D e k/1 k/a k/B k/c k/D) vs (c e k/1 k/B k/D) */ expect = default_icase ? 8 : 5; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, expect, NULL, expect, NULL); git_iterator_free(i); @@ -1291,13 +1291,13 @@ void test_repo_iterator__indexfilelist_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 3, NULL, 3, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 1, NULL, 1, NULL); git_iterator_free(i); @@ -1306,13 +1306,13 @@ void test_repo_iterator__indexfilelist_icase(void) i_opts.start = "c"; i_opts.end = "k/D"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 5, NULL, 5, NULL); git_iterator_free(i); i_opts.start = "k"; i_opts.end = "k/Z"; - cl_git_pass(git_iterator_for_index(&i, index, &i_opts)); + cl_git_pass(git_iterator_for_index(&i, g_repo, index, &i_opts)); expect_iterator_items(i, 2, NULL, 2, NULL); git_iterator_free(i); |