cocci: apply "pending" index-compatibility to "t/helper/*.c"

Apply the "index-compatibility.pending.cocci" rule to the "t/helper/*" directory, a subsequent commit will extend cache.h to further narrow down the use of "USE_THE_INDEX_COMPATIBILITY_MACROS" in this area. 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 0ea414a14dac444c52f45d4d15c0f5318dddc4b1
8 files changed +21 -20
t/helper/test-cache-tree.c
+1 -1
@@ -30,7 +30,7 @@ int cmd__cache_tree(int argc, const char **argv)
30
31 argc = parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);
32
33 - if (read_cache() < 0)
33 + if (repo_read_index(the_repository) < 0)
34 die(_("unable to read index file"));
35
36 oidcpy(&oid, &the_index.cache_tree->oid);
t/helper/test-dump-cache-tree.c
+1 -1
@@ -62,7 +62,7 @@ int cmd__dump_cache_tree(int ac, const char **av)
62 int ret;
63
64 setup_git_directory();
65 - if (read_cache() < 0)
65 + if (repo_read_index(the_repository) < 0)
66 die("unable to read index file");
67 istate = the_index;
68 istate.cache_tree = another;
t/helper/test-dump-untracked-cache.c
+1 -1
@@ -51,7 +51,7 @@ int cmd__dump_untracked_cache(int ac, const char **av)
51 xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
52
53 setup_git_directory();
54 - if (read_cache() < 0)
54 + if (repo_read_index(the_repository) < 0)
55 die("unable to read index file");
56 uc = the_index.untracked;
57 if (!uc) {
t/helper/test-fast-rebase.c
+1 -1
@@ -123,7 +123,7 @@ int cmd__fast_rebase(int argc, const char **argv)
123 die(_("Cannot read HEAD"));
124 assert(oideq(&onto->object.oid, &head));
125
126 - hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
126 + repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
127 if (repo_read_index(the_repository) < 0)
128 BUG("Could not read index");
129
t/helper/test-lazy-init-name-hash.c
+10 -10
@@ -32,7 +32,7 @@ static void dump_run(void)
32 struct dir_entry *dir;
33 struct cache_entry *ce;
34
35 - read_cache();
35 + repo_read_index(the_repository);
36 if (single) {
37 test_lazy_init_name_hash(&the_index, 0);
38 } else {
@@ -49,7 +49,7 @@ static void dump_run(void)
49 ent /* member name */)
50 printf("name %08x %s\n", ce->ent.hash, ce->name);
51
52 - discard_cache();
52 + discard_index(&the_index);
53 }
54
55 /*
@@ -66,7 +66,7 @@ static uint64_t time_runs(int try_threaded)
66
67 for (i = 0; i < count; i++) {
68 t0 = getnanotime();
69 - read_cache();
69 + repo_read_index(the_repository);
70 t1 = getnanotime();
71 nr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded);
72 t2 = getnanotime();
@@ -89,7 +89,7 @@ static uint64_t time_runs(int try_threaded)
89 the_index.cache_nr);
90 fflush(stdout);
91
92 - discard_cache();
92 + discard_index(&the_index);
93 }
94
95 avg = sum / count;
@@ -113,9 +113,9 @@ static void analyze_run(void)
113 int i;
114 int nr;
115
116 - read_cache();
116 + repo_read_index(the_repository);
117 cache_nr_limit = the_index.cache_nr;
118 - discard_cache();
118 + discard_index(&the_index);
119
120 nr = analyze;
121 while (1) {
@@ -128,23 +128,23 @@ static void analyze_run(void)
128 nr = cache_nr_limit;
129
130 for (i = 0; i < count; i++) {
131 - read_cache();
131 + repo_read_index(the_repository);
132 the_index.cache_nr = nr; /* cheap truncate of index */
133 t1s = getnanotime();
134 test_lazy_init_name_hash(&the_index, 0);
135 t2s = getnanotime();
136 sum_single += (t2s - t1s);
137 the_index.cache_nr = cache_nr_limit;
138 - discard_cache();
138 + discard_index(&the_index);
139
140 - read_cache();
140 + repo_read_index(the_repository);
141 the_index.cache_nr = nr; /* cheap truncate of index */
142 t1m = getnanotime();
143 nr_threads_used = test_lazy_init_name_hash(&the_index, 1);
144 t2m = getnanotime();
145 sum_multi += (t2m - t1m);
146 the_index.cache_nr = cache_nr_limit;
147 - discard_cache();
147 + discard_index(&the_index);
148
149 if (!nr_threads_used)
150 printf(" [size %8d] [single %f] non-threaded code path used\n",
t/helper/test-read-cache.c
+2 -2
@@ -20,7 +20,7 @@ int cmd__read_cache(int argc, const char **argv)
20 git_config(git_default_config, NULL);
21
22 for (i = 0; i < cnt; i++) {
23 - read_cache();
23 + repo_read_index(the_repository);
24 if (name) {
25 int pos;
26
@@ -33,7 +33,7 @@ int cmd__read_cache(int argc, const char **argv)
33 ce_uptodate(the_index.cache[pos]) ? "" : " not");
34 write_file(name, "%d\n", i);
35 }
36 - discard_cache();
36 + discard_index(&the_index);
37 }
38 return 0;
39 }
t/helper/test-scrap-cache-tree.c
+2 -2
@@ -9,8 +9,8 @@ int cmd__scrap_cache_tree(int ac, const char **av)
9 struct lock_file index_lock = LOCK_INIT;
10
11 setup_git_directory();
12 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
13 - if (read_cache() < 0)
12 + repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
13 + if (repo_read_index(the_repository) < 0)
14 die("unable to read index file");
15 cache_tree_free(&the_index.cache_tree);
16 the_index.cache_tree = NULL;
t/helper/test-write-cache.c
+3 -2
@@ -9,9 +9,10 @@ int cmd__write_cache(int argc, const char **argv)
9 if (argc == 2)
10 cnt = strtol(argv[1], NULL, 0);
11 setup_git_directory();
12 - read_cache();
12 + repo_read_index(the_repository);
13 for (i = 0; i < cnt; i++) {
14 - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
14 + repo_hold_locked_index(the_repository, &index_lock,
15 + LOCK_DIE_ON_ERROR);
16 if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
17 die("unable to write index file");
18 }