Merge pull request #3612 from arthurschreiber/arthur/fix-3173 Horrible fix for #3173.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
diff --git a/src/checkout.c b/src/checkout.c
index fd8e2c4..95ce3c9 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 67fab07..9ac5b92 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 081a1ea..ac4d8ee 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 ee348de..04aac3e 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 59f87e9..ac17d29 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 70c705a..d2f92cc 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 5bb69ec..8a93cdd 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 3582465..43a464e 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 6ec4c53..3e55c56 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 eafb1b9..8417e8e 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 83b8246..c18e24a 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);