Skip to content

Commit 0ea414a

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dc59418 commit 0ea414a

8 files changed

+21
-20
lines changed

t/helper/test-cache-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int cmd__cache_tree(int argc, const char **argv)
3030

3131
argc = parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);
3232

33-
if (read_cache() < 0)
33+
if (repo_read_index(the_repository) < 0)
3434
die(_("unable to read index file"));
3535

3636
oidcpy(&oid, &the_index.cache_tree->oid);

t/helper/test-dump-cache-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int cmd__dump_cache_tree(int ac, const char **av)
6262
int ret;
6363

6464
setup_git_directory();
65-
if (read_cache() < 0)
65+
if (repo_read_index(the_repository) < 0)
6666
die("unable to read index file");
6767
istate = the_index;
6868
istate.cache_tree = another;

t/helper/test-dump-untracked-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int cmd__dump_untracked_cache(int ac, const char **av)
5151
xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
5252

5353
setup_git_directory();
54-
if (read_cache() < 0)
54+
if (repo_read_index(the_repository) < 0)
5555
die("unable to read index file");
5656
uc = the_index.untracked;
5757
if (!uc) {

t/helper/test-fast-rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int cmd__fast_rebase(int argc, const char **argv)
123123
die(_("Cannot read HEAD"));
124124
assert(oideq(&onto->object.oid, &head));
125125

126-
hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
126+
repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
127127
if (repo_read_index(the_repository) < 0)
128128
BUG("Could not read index");
129129

t/helper/test-lazy-init-name-hash.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void dump_run(void)
3232
struct dir_entry *dir;
3333
struct cache_entry *ce;
3434

35-
read_cache();
35+
repo_read_index(the_repository);
3636
if (single) {
3737
test_lazy_init_name_hash(&the_index, 0);
3838
} else {
@@ -49,7 +49,7 @@ static void dump_run(void)
4949
ent /* member name */)
5050
printf("name %08x %s\n", ce->ent.hash, ce->name);
5151

52-
discard_cache();
52+
discard_index(&the_index);
5353
}
5454

5555
/*
@@ -66,7 +66,7 @@ static uint64_t time_runs(int try_threaded)
6666

6767
for (i = 0; i < count; i++) {
6868
t0 = getnanotime();
69-
read_cache();
69+
repo_read_index(the_repository);
7070
t1 = getnanotime();
7171
nr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded);
7272
t2 = getnanotime();
@@ -89,7 +89,7 @@ static uint64_t time_runs(int try_threaded)
8989
the_index.cache_nr);
9090
fflush(stdout);
9191

92-
discard_cache();
92+
discard_index(&the_index);
9393
}
9494

9595
avg = sum / count;
@@ -113,9 +113,9 @@ static void analyze_run(void)
113113
int i;
114114
int nr;
115115

116-
read_cache();
116+
repo_read_index(the_repository);
117117
cache_nr_limit = the_index.cache_nr;
118-
discard_cache();
118+
discard_index(&the_index);
119119

120120
nr = analyze;
121121
while (1) {
@@ -128,23 +128,23 @@ static void analyze_run(void)
128128
nr = cache_nr_limit;
129129

130130
for (i = 0; i < count; i++) {
131-
read_cache();
131+
repo_read_index(the_repository);
132132
the_index.cache_nr = nr; /* cheap truncate of index */
133133
t1s = getnanotime();
134134
test_lazy_init_name_hash(&the_index, 0);
135135
t2s = getnanotime();
136136
sum_single += (t2s - t1s);
137137
the_index.cache_nr = cache_nr_limit;
138-
discard_cache();
138+
discard_index(&the_index);
139139

140-
read_cache();
140+
repo_read_index(the_repository);
141141
the_index.cache_nr = nr; /* cheap truncate of index */
142142
t1m = getnanotime();
143143
nr_threads_used = test_lazy_init_name_hash(&the_index, 1);
144144
t2m = getnanotime();
145145
sum_multi += (t2m - t1m);
146146
the_index.cache_nr = cache_nr_limit;
147-
discard_cache();
147+
discard_index(&the_index);
148148

149149
if (!nr_threads_used)
150150
printf(" [size %8d] [single %f] non-threaded code path used\n",

t/helper/test-read-cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int cmd__read_cache(int argc, const char **argv)
2020
git_config(git_default_config, NULL);
2121

2222
for (i = 0; i < cnt; i++) {
23-
read_cache();
23+
repo_read_index(the_repository);
2424
if (name) {
2525
int pos;
2626

@@ -33,7 +33,7 @@ int cmd__read_cache(int argc, const char **argv)
3333
ce_uptodate(the_index.cache[pos]) ? "" : " not");
3434
write_file(name, "%d\n", i);
3535
}
36-
discard_cache();
36+
discard_index(&the_index);
3737
}
3838
return 0;
3939
}

t/helper/test-scrap-cache-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ int cmd__scrap_cache_tree(int ac, const char **av)
99
struct lock_file index_lock = LOCK_INIT;
1010

1111
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)
1414
die("unable to read index file");
1515
cache_tree_free(&the_index.cache_tree);
1616
the_index.cache_tree = NULL;

t/helper/test-write-cache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ int cmd__write_cache(int argc, const char **argv)
99
if (argc == 2)
1010
cnt = strtol(argv[1], NULL, 0);
1111
setup_git_directory();
12-
read_cache();
12+
repo_read_index(the_repository);
1313
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);
1516
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
1617
die("unable to write index file");
1718
}

0 commit comments

Comments
 (0)