diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-11-28 03:13:46 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-11-28 03:13:46 (GMT) |
commit | 041df69edd393204c220f3f39d217e284258fd18 (patch) | |
tree | 20760c6a0bcbbec48fcc4a05d8d245581d570e91 /t/helper | |
parent | 613999cc5c951bc2c078caad59e339243f119a6e (diff) | |
parent | 07047d68294769d5e8700fc200ac326a21d04f8e (diff) | |
download | git-041df69edd393204c220f3f39d217e284258fd18.zip git-041df69edd393204c220f3f39d217e284258fd18.tar.gz git-041df69edd393204c220f3f39d217e284258fd18.tar.bz2 |
Merge branch 'ab/fewer-the-index-macros'
Progress on removing 'the_index' convenience wrappers.
* ab/fewer-the-index-macros:
cocci: apply "pending" index-compatibility to some "builtin/*.c"
cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"
{builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
cocci: apply "pending" index-compatibility to "t/helper/*.c"
cocci & cache.h: apply variable section of "pending" index-compatibility
cocci & cache.h: apply a selection of "pending" index-compatibility
cocci: add a index-compatibility.pending.cocci
read-cache API & users: make discard_index() return void
cocci & cache.h: remove rarely used "the_index" compat macros
builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"
cache.h: remove unused "the_index" compat macros
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-cache-tree.c | 3 | ||||
-rw-r--r-- | t/helper/test-dump-cache-tree.c | 5 | ||||
-rw-r--r-- | t/helper/test-dump-split-index.c | 1 | ||||
-rw-r--r-- | t/helper/test-dump-untracked-cache.c | 4 | ||||
-rw-r--r-- | t/helper/test-fast-rebase.c | 4 | ||||
-rw-r--r-- | t/helper/test-lazy-init-name-hash.c | 21 | ||||
-rw-r--r-- | t/helper/test-read-cache.c | 5 | ||||
-rw-r--r-- | t/helper/test-scrap-cache-tree.c | 9 | ||||
-rw-r--r-- | t/helper/test-tool.h | 1 | ||||
-rw-r--r-- | t/helper/test-write-cache.c | 6 |
10 files changed, 33 insertions, 26 deletions
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c index 93051b2..9159a17 100644 --- a/t/helper/test-cache-tree.c +++ b/t/helper/test-cache-tree.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "tree.h" @@ -30,7 +31,7 @@ int cmd__cache_tree(int argc, const char **argv) argc = parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0); - if (read_cache() < 0) + if (repo_read_index(the_repository) < 0) die(_("unable to read index file")); oidcpy(&oid, &the_index.cache_tree->oid); diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c index 0d6d7f1..454f17b 100644 --- a/t/helper/test-dump-cache-tree.c +++ b/t/helper/test-dump-cache-tree.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "tree.h" @@ -62,12 +63,12 @@ int cmd__dump_cache_tree(int ac, const char **av) int ret; setup_git_directory(); - if (read_cache() < 0) + if (repo_read_index(the_repository) < 0) die("unable to read index file"); istate = the_index; istate.cache_tree = another; cache_tree_update(&istate, WRITE_TREE_DRY_RUN); - ret = dump_cache_tree(active_cache_tree, another, ""); + ret = dump_cache_tree(the_index.cache_tree, another, ""); cache_tree_free(&another); return ret; diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c index a209880..0ea97b8 100644 --- a/t/helper/test-dump-split-index.c +++ b/t/helper/test-dump-split-index.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "split-index.h" diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c index 9901061..6d53683 100644 --- a/t/helper/test-dump-untracked-cache.c +++ b/t/helper/test-dump-untracked-cache.c @@ -1,4 +1,4 @@ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "dir.h" @@ -51,7 +51,7 @@ int cmd__dump_untracked_cache(int ac, const char **av) xsetenv("GIT_CONFIG_VALUE_0", "keep", 1); setup_git_directory(); - if (read_cache() < 0) + if (repo_read_index(the_repository) < 0) die("unable to read index file"); uc = the_index.untracked; if (!uc) { diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c index 45665ec..efc82dd 100644 --- a/t/helper/test-fast-rebase.c +++ b/t/helper/test-fast-rebase.c @@ -10,7 +10,7 @@ * refactoring is the better route). */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache-tree.h" @@ -123,7 +123,7 @@ int cmd__fast_rebase(int argc, const char **argv) die(_("Cannot read HEAD")); assert(oideq(&onto->object.oid, &head)); - hold_locked_index(&lock, LOCK_DIE_ON_ERROR); + repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR); if (repo_read_index(the_repository) < 0) BUG("Could not read index"); diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c index cd1b4c9..ab86c14 100644 --- a/t/helper/test-lazy-init-name-hash.c +++ b/t/helper/test-lazy-init-name-hash.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "parse-options.h" @@ -32,7 +33,7 @@ static void dump_run(void) struct dir_entry *dir; struct cache_entry *ce; - read_cache(); + repo_read_index(the_repository); if (single) { test_lazy_init_name_hash(&the_index, 0); } else { @@ -49,7 +50,7 @@ static void dump_run(void) ent /* member name */) printf("name %08x %s\n", ce->ent.hash, ce->name); - discard_cache(); + discard_index(&the_index); } /* @@ -66,7 +67,7 @@ static uint64_t time_runs(int try_threaded) for (i = 0; i < count; i++) { t0 = getnanotime(); - read_cache(); + repo_read_index(the_repository); t1 = getnanotime(); nr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded); t2 = getnanotime(); @@ -89,7 +90,7 @@ static uint64_t time_runs(int try_threaded) the_index.cache_nr); fflush(stdout); - discard_cache(); + discard_index(&the_index); } avg = sum / count; @@ -113,9 +114,9 @@ static void analyze_run(void) int i; int nr; - read_cache(); + repo_read_index(the_repository); cache_nr_limit = the_index.cache_nr; - discard_cache(); + discard_index(&the_index); nr = analyze; while (1) { @@ -128,23 +129,23 @@ static void analyze_run(void) nr = cache_nr_limit; for (i = 0; i < count; i++) { - read_cache(); + repo_read_index(the_repository); the_index.cache_nr = nr; /* cheap truncate of index */ t1s = getnanotime(); test_lazy_init_name_hash(&the_index, 0); t2s = getnanotime(); sum_single += (t2s - t1s); the_index.cache_nr = cache_nr_limit; - discard_cache(); + discard_index(&the_index); - read_cache(); + repo_read_index(the_repository); the_index.cache_nr = nr; /* cheap truncate of index */ t1m = getnanotime(); nr_threads_used = test_lazy_init_name_hash(&the_index, 1); t2m = getnanotime(); sum_multi += (t2m - t1m); the_index.cache_nr = cache_nr_limit; - discard_cache(); + discard_index(&the_index); if (!nr_threads_used) printf(" [size %8d] [single %f] non-threaded code path used\n", diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index b736ef1..23e9e27 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "config.h" @@ -20,7 +21,7 @@ int cmd__read_cache(int argc, const char **argv) git_config(git_default_config, NULL); for (i = 0; i < cnt; i++) { - read_cache(); + repo_read_index(the_repository); if (name) { int pos; @@ -33,7 +34,7 @@ int cmd__read_cache(int argc, const char **argv) ce_uptodate(the_index.cache[pos]) ? "" : " not"); write_file(name, "%d\n", i); } - discard_cache(); + discard_index(&the_index); } return 0; } diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c index 026c802..a26107e 100644 --- a/t/helper/test-scrap-cache-tree.c +++ b/t/helper/test-scrap-cache-tree.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "lockfile.h" @@ -9,11 +10,11 @@ int cmd__scrap_cache_tree(int ac, const char **av) struct lock_file index_lock = LOCK_INIT; setup_git_directory(); - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR); - if (read_cache() < 0) + repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR); + if (repo_read_index(the_repository) < 0) die("unable to read index file"); - cache_tree_free(&active_cache_tree); - active_cache_tree = NULL; + cache_tree_free(&the_index.cache_tree); + the_index.cache_tree = NULL; if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK)) die("unable to write index file"); return 0; diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index da7cd63..2e20a16 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -1,7 +1,6 @@ #ifndef TEST_TOOL_H #define TEST_TOOL_H -#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "git-compat-util.h" int cmd__advise_if_enabled(int argc, const char **argv); diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c index 8837717..7d45cd6 100644 --- a/t/helper/test-write-cache.c +++ b/t/helper/test-write-cache.c @@ -1,3 +1,4 @@ +#define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" #include "lockfile.h" @@ -9,9 +10,10 @@ int cmd__write_cache(int argc, const char **argv) if (argc == 2) cnt = strtol(argv[1], NULL, 0); setup_git_directory(); - read_cache(); + repo_read_index(the_repository); for (i = 0; i < cnt; i++) { - hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR); + repo_hold_locked_index(the_repository, &index_lock, + LOCK_DIE_ON_ERROR); if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK)) die("unable to write index file"); } |