cocci: apply "pending" index-compatibility to some "builtin/*.c"

Apply "index-compatibility.pending.cocci" rule to "builtin/*", but exclude those where we conflict with in-flight changes. As a result some of them end up using only "the_index", so let's have them use the more narrow "USE_THE_INDEX_VARIABLE" rather than "USE_THE_INDEX_COMPATIBILITY_MACROS". Manual changes not made by coccinelle, that were squashed in: * Whitespace-wrap argument lists for repo_hold_locked_index(), repo_read_index_preload() and repo_refresh_and_write_index(), in cases where the line became too long after the transformation. * Change "refresh_cache()" to "refresh_index()" in a comment in "builtin/update-index.c". * For those whose call was followed by perror("<macro-name>"), change it to perror("<function-name>"), referring to the new function. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 19, 2022 at 14:07 UTC 07047d68294769d5e8700fc200ac326a21d04f8e
30 files changed +213 -202
builtin/add.c
+4 -4
@@ -3,7 +3,7 @@
3 *
4 * Copyright (C) 2006 Linus Torvalds
5 */
6 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
6 +#define USE_THE_INDEX_VARIABLE
7 #include "cache.h"
8 #include "config.h"
9 #include "builtin.h"
@@ -312,7 +312,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
312
313 git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
314
315 - if (read_cache() < 0)
315 + if (repo_read_index(the_repository) < 0)
316 die(_("Could not read the index"));
317
318 repo_init_revisions(the_repository, &rev, prefix);
@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
544 prepare_repo_settings(the_repository);
545 the_repository->settings.command_requires_full_index = 0;
546
547 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
547 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
548
549 /*
550 * Check the "pathspec '%s' did not match any files" block
@@ -587,7 +587,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
587 (!(addremove || take_worktree_changes)
588 ? ADD_CACHE_IGNORE_REMOVAL : 0));
589
590 - if (read_cache_preload(&pathspec) < 0)
590 + if (repo_read_index_preload(the_repository, &pathspec, 0) < 0)
591 die(_("index file corrupt"));
592
593 die_in_unpopulated_submodule(&the_index, prefix);
builtin/am.c
+11 -10
@@ -1519,8 +1519,8 @@ static int run_apply(const struct am_state *state, const char *index_file)
1519
1520 if (index_file) {
1521 /* Reload index as apply_all_patches() will have modified it. */
1522 - discard_cache();
1523 - read_cache_from(index_file);
1522 + discard_index(&the_index);
1523 + read_index_from(&the_index, index_file, get_git_dir());
1524 }
1525
1526 return 0;
@@ -1562,8 +1562,8 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
1562 if (build_fake_ancestor(state, index_path))
1563 return error("could not build fake ancestor");
1564
1565 - discard_cache();
1566 - read_cache_from(index_path);
1565 + discard_index(&the_index);
1566 + read_index_from(&the_index, index_path, get_git_dir());
1567
1568 if (write_index_as_tree(&orig_tree, &the_index, index_path, 0, NULL))
1569 return error(_("Repository lacks necessary blobs to fall back on 3-way merge."));
@@ -1596,8 +1596,8 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
1596
1597 say(state, stdout, _("Falling back to patching base and 3-way merge..."));
1598
1599 - discard_cache();
1600 - read_cache();
1599 + discard_index(&the_index);
1600 + repo_read_index(the_repository);
1601
1602 /*
1603 * This is not so wrong. Depending on which base we picked, orig_tree
@@ -1781,7 +1781,8 @@ static void am_run(struct am_state *state, int resume)
1781
1782 unlink(am_path(state, "dirtyindex"));
1783
1784 - if (refresh_and_write_cache(REFRESH_QUIET, 0, 0) < 0)
1784 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, 0, 0,
1785 + NULL, NULL, NULL) < 0)
1786 die(_("unable to write index file"));
1787
1788 if (repo_index_has_changes(the_repository, NULL, &sb)) {
@@ -1967,9 +1968,9 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)
1968 if (parse_tree(head) || parse_tree(remote))
1969 return -1;
1970
1970 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
1971 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
1972
1972 - refresh_cache(REFRESH_QUIET);
1973 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
1974
1975 memset(&opts, 0, sizeof(opts));
1976 opts.head_idx = 1;
@@ -2007,7 +2008,7 @@ static int merge_tree(struct tree *tree)
2008 if (parse_tree(tree))
2009 return -1;
2010
2010 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
2011 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
2012
2013 memset(&opts, 0, sizeof(opts));
2014 opts.head_idx = 1;
builtin/check-attr.c
+2 -2
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "cache.h"
4 #include "config.h"
@@ -115,7 +115,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
115 argc = parse_options(argc, argv, prefix, check_attr_options,
116 check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
117
118 - if (read_cache() < 0) {
118 + if (repo_read_index(the_repository) < 0) {
119 die("invalid cache");
120 }
121
builtin/check-ignore.c
+2 -2
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "cache.h"
4 #include "config.h"
@@ -179,7 +179,7 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)
179 die(_("--non-matching is only valid with --verbose"));
180
181 /* read_cache() is only necessary so we can watch out for submodules. */
182 - if (!no_index && read_cache() < 0)
182 + if (!no_index && repo_read_index(the_repository) < 0)
183 die(_("index file corrupt"));
184
185 setup_standard_excludes(&dir);
builtin/checkout-index.c
+5 -4
@@ -4,7 +4,7 @@
4 * Copyright (C) 2005 Linus Torvalds
5 *
6 */
7 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
7 +#define USE_THE_INDEX_VARIABLE
8 #include "builtin.h"
9 #include "config.h"
10 #include "dir.h"
@@ -65,7 +65,7 @@ static void write_tempfile_record(const char *name, const char *prefix)
65 static int checkout_file(const char *name, const char *prefix)
66 {
67 int namelen = strlen(name);
68 - int pos = cache_name_pos(name, namelen);
68 + int pos = index_name_pos(&the_index, name, namelen);
69 int has_same_name = 0;
70 int is_file = 0;
71 int is_skipped = 1;
@@ -249,7 +249,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
249 prepare_repo_settings(the_repository);
250 the_repository->settings.command_requires_full_index = 0;
251
252 - if (read_cache() < 0) {
252 + if (repo_read_index(the_repository) < 0) {
253 die("invalid cache");
254 }
255
@@ -270,7 +270,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
270 if (index_opt && !state.base_dir_len && !to_tempfile) {
271 state.refresh_cache = 1;
272 state.istate = &the_index;
273 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
273 + repo_hold_locked_index(the_repository, &lock_file,
274 + LOCK_DIE_ON_ERROR);
275 }
276
277 get_parallel_checkout_configs(&pc_workers, &pc_threshold);
builtin/checkout.c
+6 -6
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "advice.h"
4 #include "blob.h"
@@ -148,7 +148,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
148 * entry in place. Whether it is UPTODATE or not, checkout_entry will
149 * do the right thing.
150 */
151 - pos = cache_name_pos(ce->name, ce->ce_namelen);
151 + pos = index_name_pos(&the_index, ce->name, ce->ce_namelen);
152 if (pos >= 0) {
153 struct cache_entry *old = the_index.cache[pos];
154 if (ce->ce_mode == old->ce_mode &&
@@ -529,7 +529,7 @@ static int checkout_paths(const struct checkout_opts *opts,
529 }
530
531 repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
532 - if (read_cache_preload(&opts->pathspec) < 0)
532 + if (repo_read_index_preload(the_repository, &opts->pathspec, 0) < 0)
533 return error(_("index file corrupt"));
534
535 if (opts->source_tree)
@@ -741,8 +741,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
741 struct lock_file lock_file = LOCK_INIT;
742 struct tree *new_tree;
743
744 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
745 - if (read_cache_preload(NULL) < 0)
744 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
745 + if (repo_read_index_preload(the_repository, NULL, 0) < 0)
746 return error(_("index file corrupt"));
747
748 resolve_undo_clear_index(&the_index);
@@ -762,7 +762,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
762 struct unpack_trees_options topts;
763 const struct object_id *old_commit_oid;
764
765 - refresh_cache(REFRESH_QUIET);
765 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
766
767 if (unmerged_index(&the_index)) {
768 error(_("you need to resolve your current index first"));
builtin/clean.c
+2 -2
@@ -6,7 +6,7 @@
6 * Based on git-clean.sh by Pavel Roskin
7 */
8
9 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
9 +#define USE_THE_INDEX_VARIABLE
10 #include "builtin.h"
11 #include "cache.h"
12 #include "config.h"
@@ -1012,7 +1012,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
1012 prepare_repo_settings(the_repository);
1013 the_repository->settings.command_requires_full_index = 0;
1014
1015 - if (read_cache() < 0)
1015 + if (repo_read_index(the_repository) < 0)
1016 die(_("index file corrupt"));
1017
1018 pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
builtin/clone.c
+2 -2
@@ -8,7 +8,7 @@
8 * Clone a repository into a different directory that does not yet exist.
9 */
10
11 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
11 +#define USE_THE_INDEX_VARIABLE
12 #include "builtin.h"
13 #include "config.h"
14 #include "lockfile.h"
@@ -703,7 +703,7 @@ static int checkout(int submodule_progress, int filter_submodules)
703 /* We need to be in the new work tree for the checkout */
704 setup_work_tree();
705
706 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
706 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
707
708 memset(&opts, 0, sizeof opts);
709 opts.update = 1;
builtin/commit.c
+22 -18
@@ -316,7 +316,7 @@ static void create_base_index(const struct commit *current_head)
316 struct tree_desc t;
317
318 if (!current_head) {
319 - discard_cache();
319 + discard_index(&the_index);
320 return;
321 }
322
@@ -343,7 +343,7 @@ static void refresh_cache_or_die(int refresh_flags)
343 * refresh_flags contains REFRESH_QUIET, so the only errors
344 * are for unmerged entries.
345 */
346 - if (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN))
346 + if (refresh_index(&the_index, refresh_flags | REFRESH_IN_PORCELAIN, NULL, NULL, NULL))
347 die_resolve_conflict("commit");
348 }
349
@@ -382,12 +382,13 @@ static const char *prepare_index(const char **argv, const char *prefix,
382 (!amend || (fixup_message && strcmp(fixup_prefix, "amend"))))))
383 die(_("No paths with --include/--only does not make sense."));
384
385 - if (read_cache_preload(&pathspec) < 0)
385 + if (repo_read_index_preload(the_repository, &pathspec, 0) < 0)
386 die(_("index file corrupt"));
387
388 if (interactive) {
389 char *old_index_env = NULL, *old_repo_index_file;
390 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
390 + repo_hold_locked_index(the_repository, &index_lock,
391 + LOCK_DIE_ON_ERROR);
392
393 refresh_cache_or_die(refresh_flags);
394
@@ -410,8 +411,9 @@ static const char *prepare_index(const char **argv, const char *prefix,
411 unsetenv(INDEX_ENVIRONMENT);
412 FREE_AND_NULL(old_index_env);
413
413 - discard_cache();
414 - read_cache_from(get_lock_file_path(&index_lock));
414 + discard_index(&the_index);
415 + read_index_from(&the_index, get_lock_file_path(&index_lock),
416 + get_git_dir());
417 if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
418 if (reopen_lock_file(&index_lock) < 0)
419 die(_("unable to write index file"));
@@ -438,7 +440,8 @@ static const char *prepare_index(const char **argv, const char *prefix,
440 * (B) on failure, rollback the real index.
441 */
442 if (all || (also && pathspec.nr)) {
441 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
443 + repo_hold_locked_index(the_repository, &index_lock,
444 + LOCK_DIE_ON_ERROR);
445 add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
446 refresh_cache_or_die(refresh_flags);
447 update_main_cache_tree(WRITE_TREE_SILENT);
@@ -459,7 +462,8 @@ static const char *prepare_index(const char **argv, const char *prefix,
462 * We still need to refresh the index here.
463 */
464 if (!only && !pathspec.nr) {
462 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
465 + repo_hold_locked_index(the_repository, &index_lock,
466 + LOCK_DIE_ON_ERROR);
467 refresh_cache_or_die(refresh_flags);
468 if (the_index.cache_changed
469 || !cache_tree_fully_valid(the_index.cache_tree))
@@ -505,13 +509,13 @@ static const char *prepare_index(const char **argv, const char *prefix,
509 if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
510 exit(1);
511
508 - discard_cache();
509 - if (read_cache() < 0)
512 + discard_index(&the_index);
513 + if (repo_read_index(the_repository) < 0)
514 die(_("cannot read the index"));
515
512 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
516 + repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
517 add_remove_files(&partial);
514 - refresh_cache(REFRESH_QUIET);
518 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
519 update_main_cache_tree(WRITE_TREE_SILENT);
520 if (write_locked_index(&the_index, &index_lock, 0))
521 die(_("unable to write new_index file"));
@@ -523,14 +527,14 @@ static const char *prepare_index(const char **argv, const char *prefix,
527
528 create_base_index(current_head);
529 add_remove_files(&partial);
526 - refresh_cache(REFRESH_QUIET);
530 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
531
532 if (write_locked_index(&the_index, &false_lock, 0))
533 die(_("unable to write temporary index file"));
534
531 - discard_cache();
535 + discard_index(&the_index);
536 ret = get_lock_file_path(&false_lock);
533 - read_cache_from(ret);
537 + read_index_from(&the_index, ret, get_git_dir());
538 out:
539 string_list_clear(&partial, 0);
540 clear_pathspec(&pathspec);
@@ -1068,9 +1072,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1072 * and could have updated it. We must do this before we invoke
1073 * the editor and after we invoke run_status above.
1074 */
1071 - discard_cache();
1075 + discard_index(&the_index);
1076 }
1073 - read_cache_from(index_file);
1077 + read_index_from(&the_index, index_file, get_git_dir());
1078
1079 if (update_main_cache_tree(0)) {
1080 error(_("Error building trees"));
@@ -1556,7 +1560,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1560 &s.pathspec, NULL, NULL);
1561
1562 if (use_optional_locks())
1559 - fd = hold_locked_index(&index_lock, 0);
1563 + fd = repo_hold_locked_index(the_repository, &index_lock, 0);
1564 else
1565 fd = -1;
1566
builtin/describe.c
+4 -3
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "cache.h"
3 #include "config.h"
4 #include "lockfile.h"
@@ -653,10 +653,11 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
653 int fd, result;
654
655 setup_work_tree();
656 - read_cache();
656 + repo_read_index(the_repository);
657 refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
658 NULL, NULL, NULL);
659 - fd = hold_locked_index(&index_lock, 0);
659 + fd = repo_hold_locked_index(the_repository,
660 + &index_lock, 0);
661 if (0 <= fd)
662 repo_update_index_if_able(the_repository, &index_lock);
663
builtin/diff-files.c
+2 -3
@@ -3,7 +3,6 @@
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
6 #include "cache.h"
7 #include "config.h"
8 #include "diff.h"
@@ -76,8 +75,8 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
75 (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
76 diff_merges_set_dense_combined_if_unset(&rev);
77
79 - if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
80 - perror("read_cache_preload");
78 + if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
79 + perror("repo_read_index_preload");
80 result = -1;
81 goto cleanup;
82 }
builtin/diff-index.c
+4 -5
@@ -1,4 +1,3 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 #include "cache.h"
2 #include "config.h"
3 #include "diff.h"
@@ -62,12 +61,12 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
61 usage(diff_cache_usage);
62 if (!(option & DIFF_INDEX_CACHED)) {
63 setup_work_tree();
65 - if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
66 - perror("read_cache_preload");
64 + if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
65 + perror("repo_read_index_preload");
66 return -1;
67 }
69 - } else if (read_cache() < 0) {
70 - perror("read_cache");
68 + } else if (repo_read_index(the_repository) < 0) {
69 + perror("repo_read_index");
70 return -1;
71 }
72 result = run_diff_index(&rev, option);
builtin/diff-tree.c
+2 -2
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "cache.h"
3 #include "config.h"
4 #include "diff.h"
@@ -120,7 +120,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
120
121 git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
122 repo_init_revisions(the_repository, opt, prefix);
123 - if (read_cache() < 0)
123 + if (repo_read_index(the_repository) < 0)
124 die(_("index file corrupt"));
125 opt->abbrev = 0;
126 opt->diff = 1;
builtin/diff.c
+14 -11
@@ -3,7 +3,7 @@
3 *
4 * Copyright (c) 2006 Junio C Hamano
5 */
6 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
6 +#define USE_THE_INDEX_VARIABLE
7 #include "cache.h"
8 #include "config.h"
9 #include "ewah/ewok.h"
@@ -157,12 +157,13 @@ static int builtin_diff_index(struct rev_info *revs,
157 usage(builtin_diff_usage);
158 if (!(option & DIFF_INDEX_CACHED)) {
159 setup_work_tree();
160 - if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
161 - perror("read_cache_preload");
160 + if (repo_read_index_preload(the_repository,
161 + &revs->diffopt.pathspec, 0) < 0) {
162 + perror("repo_read_index_preload");
163 return -1;
164 }
164 - } else if (read_cache() < 0) {
165 - perror("read_cache");
165 + } else if (repo_read_index(the_repository) < 0) {
166 + perror("repo_read_cache");
167 return -1;
168 }
169 return run_diff_index(revs, option);
@@ -239,12 +240,13 @@ static void refresh_index_quietly(void)
240 struct lock_file lock_file = LOCK_INIT;
241 int fd;
242
242 - fd = hold_locked_index(&lock_file, 0);
243 + fd = repo_hold_locked_index(the_repository, &lock_file, 0);
244 if (fd < 0)
245 return;
245 - discard_cache();
246 - read_cache();
247 - refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
246 + discard_index(&the_index);
247 + repo_read_index(the_repository);
248 + refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL,
249 + NULL);
250 repo_update_index_if_able(the_repository, &lock_file);
251 }
252
@@ -279,8 +281,9 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
281 diff_merges_set_dense_combined_if_unset(revs);
282
283 setup_work_tree();
282 - if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
283 - perror("read_cache_preload");
284 + if (repo_read_index_preload(the_repository, &revs->diffopt.pathspec,
285 + 0) < 0) {
286 + perror("repo_read_index_preload");
287 return -1;
288 }
289 return run_diff_files(revs, options);
builtin/fsck.c
+2 -2
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "cache.h"
4 #include "repository.h"
@@ -958,7 +958,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
958 if (keep_cache_objects) {
959 verify_index_checksum = 1;
960 verify_ce_order = 1;
961 - read_cache();
961 + repo_read_index(the_repository);
962 /* TODO: audit for interaction with sparse-index. */
963 ensure_full_index(&the_index);
964 for (i = 0; i < the_index.cache_nr; i++) {
builtin/merge-index.c
+3 -3
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "run-command.h"
4
@@ -47,7 +47,7 @@ static int merge_entry(int pos, const char *path)
47
48 static void merge_one_path(const char *path)
49 {
50 - int pos = cache_name_pos(path, strlen(path));
50 + int pos = index_name_pos(&the_index, path, strlen(path));
51
52 /*
53 * If it already exists in the cache as stage0, it's
@@ -82,7 +82,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
82 if (argc < 3)
83 usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])");
84
85 - read_cache();
85 + repo_read_index(the_repository);
86
87 /* TODO: audit for interaction with sparse-index. */
88 ensure_full_index(&the_index);
builtin/merge-ours.c
+1 -2
@@ -7,7 +7,6 @@
7 *
8 * Pretend we resolved the heads, but declare our tree trumps everybody else.
9 */
10 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
10 #include "git-compat-util.h"
11 #include "builtin.h"
12 #include "diff.h"
@@ -25,7 +24,7 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)
24 * commit. The index must match HEAD, or this merge cannot go
25 * through.
26 */
28 - if (read_cache() < 0)
27 + if (repo_read_index(the_repository) < 0)
28 die_errno("read_cache failed");
29 if (index_differs_from(the_repository, "HEAD", NULL, 0))
30 return 2;
builtin/merge.c
+12 -7
@@ -318,7 +318,7 @@ static int save_state(struct object_id *stash)
318 int rc = -1;
319
320 fd = repo_hold_locked_index(the_repository, &lock_file, 0);
321 - refresh_cache(REFRESH_QUIET);
321 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
322 if (0 <= fd)
323 repo_update_index_if_able(the_repository, &lock_file);
324 rollback_lock_file(&lock_file);
@@ -716,7 +716,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
716 {
717 const char *head_arg = "HEAD";
718
719 - if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0)
719 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET,
720 + SKIP_IF_UNCHANGED, 0, NULL, NULL,
721 + NULL) < 0)
722 return error(_("Unable to write index."));
723
724 if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree") ||
@@ -750,7 +752,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
752 for (j = common; j; j = j->next)
753 commit_list_insert(j->item, &reversed);
754
753 - hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
755 + repo_hold_locked_index(the_repository, &lock,
756 + LOCK_DIE_ON_ERROR);
757 if (!strcmp(strategy, "ort"))
758 clean = merge_ort_recursive(&o, head, remoteheads->item,
759 reversed, &result);
@@ -859,9 +862,9 @@ static void prepare_to_commit(struct commit_list *remoteheads)
862 * the editor and after we invoke run_status above.
863 */
864 if (invoked_hook)
862 - discard_cache();
865 + discard_index(&the_index);
866 }
864 - read_cache_from(index_file);
867 + read_index_from(&the_index, index_file, get_git_dir());
868 strbuf_addbuf(&msg, &merge_msg);
869 if (squash)
870 BUG("the control must not reach here under --squash");
@@ -910,7 +913,9 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
913 struct object_id result_tree, result_commit;
914 struct commit_list *parents, **pptr = &parents;
915
913 - if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0)
916 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET,
917 + SKIP_IF_UNCHANGED, 0, NULL, NULL,
918 + NULL) < 0)
919 return error(_("Unable to write index."));
920
921 write_tree_trivial(&result_tree);
@@ -1602,7 +1607,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1607 * We are not doing octopus, not fast-forward, and have
1608 * only one common.
1609 */
1605 - refresh_cache(REFRESH_QUIET);
1610 + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
1611 if (allow_trivial && fast_forward != FF_ONLY) {
1612 /*
1613 * Must first ensure that index matches HEAD before
builtin/mv.c
+8 -8
@@ -106,7 +106,7 @@ static int index_range_of_same_dir(const char *src, int length,
106 const char *src_w_slash = add_slash(src);
107 int first, last, len_w_slash = length + 1;
108
109 - first = cache_name_pos(src_w_slash, len_w_slash);
109 + first = index_name_pos(&the_index, src_w_slash, len_w_slash);
110 if (first >= 0)
111 die(_("%.*s is in index"), len_w_slash, src_w_slash);
112
@@ -136,7 +136,7 @@ static int empty_dir_has_sparse_contents(const char *name)
136 const char *with_slash = add_slash(name);
137 int length = strlen(with_slash);
138
139 - int pos = cache_name_pos(with_slash, length);
139 + int pos = index_name_pos(&the_index, with_slash, length);
140 const struct cache_entry *ce;
141
142 if (pos < 0) {
@@ -189,8 +189,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
189 if (--argc < 1)
190 usage_with_options(builtin_mv_usage, builtin_mv_options);
191
192 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
193 - if (read_cache() < 0)
192 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
193 + if (repo_read_index(the_repository) < 0)
194 die(_("index file corrupt"));
195
196 source = internal_prefix_pathspec(prefix, argv, argc, 0);
@@ -255,7 +255,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
255 int pos;
256 const struct cache_entry *ce;
257
258 - pos = cache_name_pos(src, length);
258 + pos = index_name_pos(&the_index, src, length);
259 if (pos < 0) {
260 const char *src_w_slash = add_slash(src);
261 if (!path_in_sparse_checkout(src_w_slash, &the_index) &&
@@ -278,7 +278,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
278 goto act_on_entry;
279 }
280 /* Check if dst exists in index */
281 - if (cache_name_pos(dst, strlen(dst)) < 0) {
281 + if (index_name_pos(&the_index, dst, strlen(dst)) < 0) {
282 modes[i] |= SPARSE;
283 goto act_on_entry;
284 }
@@ -303,7 +303,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
303 dir_check:
304 if (S_ISDIR(st.st_mode)) {
305 int j, dst_len, n;
306 - int first = cache_name_pos(src, length), last;
306 + int first = index_name_pos(&the_index, src, length), last;
307
308 if (first >= 0) {
309 prepare_move_submodule(src, first,
@@ -468,7 +468,7 @@ remove_entry:
468 if (mode & (WORKING_DIRECTORY | SKIP_WORKTREE_DIR))
469 continue;
470
471 - pos = cache_name_pos(src, strlen(src));
471 + pos = index_name_pos(&the_index, src, strlen(src));
472 assert(pos >= 0);
473 if (!(mode & SPARSE) && !lstat(src, &st))
474 sparse_and_dirty = ie_modified(&the_index,
builtin/read-tree.c
+2 -2
@@ -4,7 +4,7 @@
4 * Copyright (C) Linus Torvalds, 2005
5 */
6
7 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
7 +#define USE_THE_INDEX_VARIABLE
8 #include "cache.h"
9 #include "config.h"
10 #include "lockfile.h"
@@ -176,7 +176,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
176 prepare_repo_settings(the_repository);
177 the_repository->settings.command_requires_full_index = 0;
178
179 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
179 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
180
181 /*
182 * NEEDSWORK
builtin/rebase.c
+3 -3
@@ -4,7 +4,7 @@
4 * Copyright (c) 2018 Pratik Karki
5 */
6
7 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
7 +#define USE_THE_INDEX_VARIABLE
8 #include "builtin.h"
9 #include "run-command.h"
10 #include "exec-cmd.h"
@@ -292,7 +292,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
292 if (ret)
293 error(_("could not generate todo list"));
294 else {
295 - discard_cache();
295 + discard_index(&the_index);
296 if (todo_list_parse_insn_buffer(the_repository, todo_list.buf.buf,
297 &todo_list))
298 BUG("unusable todo list");
@@ -1268,7 +1268,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1268 if (get_oid("HEAD", &head))
1269 die(_("Cannot read HEAD"));
1270
1271 - fd = hold_locked_index(&lock_file, 0);
1271 + fd = repo_hold_locked_index(the_repository, &lock_file, 0);
1272 if (repo_read_index(the_repository) < 0)
1273 die(_("could not read index"));
1274 refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL,
builtin/reset.c
+5 -4
@@ -7,7 +7,7 @@
7 *
8 * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
9 */
10 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
10 +#define USE_THE_INDEX_VARIABLE
11 #include "builtin.h"
12 #include "config.h"
13 #include "lockfile.h"
@@ -160,7 +160,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
160 * if this entry is outside the sparse cone - this is necessary
161 * to properly construct the reset sparse directory.
162 */
163 - pos = cache_name_pos(one->path, strlen(one->path));
163 + pos = index_name_pos(&the_index, one->path, strlen(one->path));
164 if ((pos >= 0 && ce_skip_worktree(the_index.cache[pos])) ||
165 (pos < 0 && !path_in_sparse_checkout(one->path, &the_index)))
166 ce->ce_flags |= CE_SKIP_WORKTREE;
@@ -423,7 +423,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
423 prepare_repo_settings(the_repository);
424 the_repository->settings.command_requires_full_index = 0;
425
426 - if (read_cache() < 0)
426 + if (repo_read_index(the_repository) < 0)
427 die(_("index file corrupt"));
428
429 /* Soft reset does not touch the index file nor the working tree
@@ -434,7 +434,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
434
435 if (reset_type != SOFT) {
436 struct lock_file lock = LOCK_INIT;
437 - hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
437 + repo_hold_locked_index(the_repository, &lock,
438 + LOCK_DIE_ON_ERROR);
439 if (reset_type == MIXED) {
440 int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
441 if (read_from_tree(&pathspec, &oid, intent_to_add))
builtin/rev-parse.c
+2 -2
@@ -3,7 +3,7 @@
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
6 +#define USE_THE_INDEX_VARIABLE
7 #include "cache.h"
8 #include "config.h"
9 #include "commit.h"
@@ -997,7 +997,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
997 continue;
998 }
999 if (!strcmp(arg, "--shared-index-path")) {
1000 - if (read_cache() < 0)
1000 + if (repo_read_index(the_repository) < 0)
1001 die(_("Could not read the index"));
1002 if (the_index.split_index) {
1003 const struct object_id *oid = &the_index.split_index->base_oid;
builtin/rm.c
+4 -4
@@ -72,7 +72,7 @@ static void submodules_absorb_gitdir_if_needed(void)
72 int pos;
73 const struct cache_entry *ce;
74
75 - pos = cache_name_pos(name, strlen(name));
75 + pos = index_name_pos(&the_index, name, strlen(name));
76 if (pos < 0) {
77 pos = get_ours_cache_pos(name, pos);
78 if (pos < 0)
@@ -117,7 +117,7 @@ static int check_local_mod(struct object_id *head, int index_only)
117 int local_changes = 0;
118 int staged_changes = 0;
119
120 - pos = cache_name_pos(name, strlen(name));
120 + pos = index_name_pos(&the_index, name, strlen(name));
121 if (pos < 0) {
122 /*
123 * Skip unmerged entries except for populated submodules
@@ -291,9 +291,9 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
291
292 prepare_repo_settings(the_repository);
293 the_repository->settings.command_requires_full_index = 0;
294 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
294 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
295
296 - if (read_cache() < 0)
296 + if (repo_read_index(the_repository) < 0)
297 die(_("index file corrupt"));
298
299 refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &pathspec, NULL, NULL);
builtin/stash.c
+19 -16
@@ -261,11 +261,11 @@ static int reset_tree(struct object_id *i_tree, int update, int reset)
261 struct tree *tree;
262 struct lock_file lock_file = LOCK_INIT;
263
264 - read_cache_preload(NULL);
265 - if (refresh_cache(REFRESH_QUIET))
264 + repo_read_index_preload(the_repository, NULL, 0);
265 + if (refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL))
266 return -1;
267
268 - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
268 + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
269
270 memset(&opts, 0, sizeof(opts));
271
@@ -523,8 +523,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
523 struct tree *head, *merge, *merge_base;
524 struct lock_file lock = LOCK_INIT;
525
526 - read_cache_preload(NULL);
527 - if (refresh_and_write_cache(REFRESH_QUIET, 0, 0))
526 + repo_read_index_preload(the_repository, NULL, 0);
527 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, 0, 0,
528 + NULL, NULL, NULL))
529 return -1;
530
531 if (write_cache_as_tree(&c_tree, 0, NULL))
@@ -549,14 +550,14 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
550 return error(_("conflicts in index. "
551 "Try without --index."));
552
552 - discard_cache();
553 - read_cache();
553 + discard_index(&the_index);
554 + repo_read_index(the_repository);
555 if (write_cache_as_tree(&index_tree, 0, NULL))
556 return error(_("could not save index tree"));
557
558 reset_head();
558 - discard_cache();
559 - read_cache();
559 + discard_index(&the_index);
560 + repo_read_index(the_repository);
561 }
562 }
563
@@ -1082,7 +1083,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
1083 if (get_oid("HEAD", &dummy))
1084 return -1;
1085
1085 - if (read_cache() < 0)
1086 + if (repo_read_index(the_repository) < 0)
1087 return -1;
1088
1089 init_revisions(&rev, NULL);
@@ -1286,7 +1287,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
1287 rev.diffopt.format_callback = add_diff_to_buf;
1288 rev.diffopt.format_callback_data = &diff_output;
1289
1289 - if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
1290 + if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
1291 ret = -1;
1292 goto done;
1293 }
@@ -1344,8 +1345,9 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
1345
1346 prepare_fallback_ident("git stash", "git@stash");
1347
1347 - read_cache_preload(NULL);
1348 - if (refresh_and_write_cache(REFRESH_QUIET, 0, 0) < 0) {
1348 + repo_read_index_preload(the_repository, NULL, 0);
1349 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, 0, 0,
1350 + NULL, NULL, NULL) < 0) {
1351 ret = -1;
1352 goto done;
1353 }
@@ -1513,7 +1515,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1515 goto done;
1516 }
1517
1516 - read_cache_preload(NULL);
1518 + repo_read_index_preload(the_repository, NULL, 0);
1519 if (!include_untracked && ps->nr) {
1520 int i;
1521 char *ps_matched = xcalloc(ps->nr, 1);
@@ -1533,7 +1535,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1535 free(ps_matched);
1536 }
1537
1536 - if (refresh_and_write_cache(REFRESH_QUIET, 0, 0)) {
1538 + if (repo_refresh_and_write_index(the_repository, REFRESH_QUIET, 0, 0,
1539 + NULL, NULL, NULL)) {
1540 ret = -1;
1541 goto done;
1542 }
@@ -1590,7 +1593,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1593 goto done;
1594 }
1595 }
1593 - discard_cache();
1596 + discard_index(&the_index);
1597 if (ps->nr) {
1598 struct child_process cp_add = CHILD_PROCESS_INIT;
1599 struct child_process cp_diff = CHILD_PROCESS_INIT;
builtin/submodule--helper.c
+7 -7
@@ -1,4 +1,4 @@
1 -#define USE_THE_INDEX_COMPATIBILITY_MACROS
1 +#define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "repository.h"
4 #include "cache.h"
@@ -196,7 +196,7 @@ static int module_list_compute(const char **argv,
196 if (pathspec->nr)
197 ps_matched = xcalloc(pathspec->nr, 1);
198
199 - if (read_cache() < 0)
199 + if (repo_read_index(the_repository) < 0)
200 die(_("index file corrupt"));
201
202 for (i = 0; i < the_index.cache_nr; i++) {
@@ -1109,13 +1109,13 @@ static int compute_summary_module_list(struct object_id *head_oid,
1109 if (!info->cached) {
1110 if (diff_cmd == DIFF_INDEX)
1111 setup_work_tree();
1112 - if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
1113 - perror("read_cache_preload");
1112 + if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
1113 + perror("repo_read_index_preload");
1114 ret = -1;
1115 goto cleanup;
1116 }
1117 - } else if (read_cache() < 0) {
1118 - perror("read_cache");
1117 + } else if (repo_read_index(the_repository) < 0) {
1118 + perror("repo_read_cache");
1119 ret = -1;
1120 goto cleanup;
1121 }
@@ -3240,7 +3240,7 @@ static void die_on_index_match(const char *path, int force)
3240 const char *args[] = { path, NULL };
3241 parse_pathspec(&ps, 0, PATHSPEC_PREFER_CWD, NULL, args);
3242
3243 - if (read_cache_preload(NULL) < 0)
3243 + if (repo_read_index_preload(the_repository, NULL, 0) < 0)
3244 die(_("index file corrupt"));
3245
3246 if (ps.nr) {
builtin/update-index.c
+10 -9
@@ -237,7 +237,7 @@ done:
237 static int mark_ce_flags(const char *path, int flag, int mark)
238 {
239 int namelen = strlen(path);
240 - int pos = cache_name_pos(path, namelen);
240 + int pos = index_name_pos(&the_index, path, namelen);
241 if (0 <= pos) {
242 mark_fsmonitor_invalid(&the_index, the_index.cache[pos]);
243 if (mark)
@@ -331,7 +331,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
331 static int process_directory(const char *path, int len, struct stat *st)
332 {
333 struct object_id oid;
334 - int pos = cache_name_pos(path, len);
334 + int pos = index_name_pos(&the_index, path, len);
335
336 /* Exact match: file or existing gitlink */
337 if (pos >= 0) {
@@ -441,7 +441,7 @@ static void chmod_path(char flip, const char *path)
441 int pos;
442 struct cache_entry *ce;
443
444 - pos = cache_name_pos(path, strlen(path));
444 + pos = index_name_pos(&the_index, path, strlen(path));
445 if (pos < 0)
446 goto fail;
447 ce = the_index.cache[pos];
@@ -638,7 +638,7 @@ static int unresolve_one(const char *path)
638 struct cache_entry *ce_2 = NULL, *ce_3 = NULL;
639
640 /* See if there is such entry in the index. */
641 - pos = cache_name_pos(path, namelen);
641 + pos = index_name_pos(&the_index, path, namelen);
642 if (0 <= pos) {
643 /* already merged */
644 pos = unmerge_index_entry_at(&the_index, pos);
@@ -802,15 +802,16 @@ struct refresh_params {
802 static int refresh(struct refresh_params *o, unsigned int flag)
803 {
804 setup_work_tree();
805 - read_cache();
806 - *o->has_errors |= refresh_cache(o->flags | flag);
805 + repo_read_index(the_repository);
806 + *o->has_errors |= refresh_index(&the_index, o->flags | flag, NULL,
807 + NULL, NULL);
808 if (has_racy_timestamp(&the_index)) {
809 /*
810 * Even if nothing else has changed, updating the file
811 * increases the chance that racy timestamps become
812 * non-racy, helping future run-time performance.
813 * We do that even in case of "errors" returned by
813 - * refresh_cache() as these are no actual errors.
814 + * refresh_index() as these are no actual errors.
815 * cmd_status() does the same.
816 */
817 the_index.cache_changed |= SOMETHING_CHANGED;
@@ -1109,11 +1110,11 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1110 the_repository->settings.command_requires_full_index = 0;
1111
1112 /* we will diagnose later if it turns out that we need to update it */
1112 - newfd = hold_locked_index(&lock_file, 0);
1113 + newfd = repo_hold_locked_index(the_repository, &lock_file, 0);
1114 if (newfd < 0)
1115 lock_error = errno;
1116
1116 - entries = read_cache();
1117 + entries = repo_read_index(the_repository);
1118 if (entries < 0)
1119 die("cache corrupted");
1120
cache.h
-5
@@ -441,13 +441,8 @@ extern struct index_state the_index;
441 #define active_nr (the_index.cache_nr)
442
443 #define read_cache() repo_read_index(the_repository)
444 -#define read_cache_from(path) read_index_from(&the_index, (path), (get_git_dir()))
445 -#define read_cache_preload(pathspec) repo_read_index_preload(the_repository, (pathspec), 0)
444 #define discard_cache() discard_index(&the_index)
445 #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
448 -#define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
449 -#define refresh_and_write_cache(refresh_flags, write_flags, gentle) repo_refresh_and_write_index(the_repository, (refresh_flags), (write_flags), (gentle), NULL, NULL, NULL)
450 -#define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
446 #endif
447 #endif
448 #endif
contrib/coccinelle/index-compatibility.cocci
+53
@@ -26,11 +26,27 @@ identifier f != prepare_to_commit;
26 (
27 - read_cache_unmerged
28 + repo_read_index_unmerged
29 +|
30 +- hold_locked_index
31 ++ repo_hold_locked_index
32 )
33 (
34 + the_repository,
35 ...)
36
37 +// "the_repository" special-cases
38 +@@
39 +@@
40 +(
41 +- read_cache_preload
42 ++ repo_read_index_preload
43 +)
44 + (
45 ++ the_repository,
46 + ...
47 ++ , 0
48 + )
49 +
50 // "the_index" simple cases
51 @@
52 @@
@@ -80,3 +96,40 @@ identifier f != prepare_to_commit;
96 (
97 + &the_index,
98 ...)
99 +
100 +@@
101 +@@
102 +(
103 +- refresh_and_write_cache
104 ++ repo_refresh_and_write_index
105 +)
106 + (
107 ++ the_repository,
108 + ...
109 ++ , NULL, NULL, NULL
110 + )
111 +
112 +// "the_index" special-cases
113 +@@
114 +@@
115 +(
116 +- read_cache_from
117 ++ read_index_from
118 +)
119 + (
120 ++ &the_index,
121 + ...
122 ++ , get_git_dir()
123 + )
124 +
125 +@@
126 +@@
127 +(
128 +- refresh_cache
129 ++ refresh_index
130 +)
131 + (
132 ++ &the_index,
133 + ...
134 ++ , NULL, NULL, NULL
135 + )
contrib/coccinelle/index-compatibility.pending.cocci
-54
@@ -4,9 +4,6 @@
4 (
5 - read_cache
6 + repo_read_index
7 -|
8 -- hold_locked_index
9 -+ repo_hold_locked_index
7 )
8 (
9 + the_repository,
@@ -25,54 +22,3 @@
22 (
23 + &the_index,
24 ...)
28 -
29 -// "the_repository" special-cases
30 -@@
31 -@@
32 -(
33 -- read_cache_preload
34 -+ repo_read_index_preload
35 -)
36 - (
37 -+ the_repository,
38 - ...
39 -+ , 0
40 - )
41 -
42 -@@
43 -@@
44 -(
45 -- refresh_and_write_cache
46 -+ repo_refresh_and_write_index
47 -)
48 - (
49 -+ the_repository,
50 - ...
51 -+ , NULL, NULL, NULL
52 - )
53 -
54 -
55 -// "the_index" special-cases
56 -@@
57 -@@
58 -(
59 -- read_cache_from
60 -+ read_index_from
61 -)
62 - (
63 -+ &the_index,
64 - ...
65 -+ , get_git_dir()
66 - )
67 -
68 -@@
69 -@@
70 -(
71 -- refresh_cache
72 -+ refresh_index
73 -)
74 - (
75 -+ &the_index,
76 - ...
77 -+ , NULL, NULL, NULL
78 - )