From d850b7a545fcfbd97460a921c7f7c59d933eb0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Mar 2023 15:58:46 +0200 Subject: cocci: apply the "cache.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "cache.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 35e5657877..d6c69164d0 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo, if (tree) cmp = tree->object.oid; - if (tree || !get_oid_tree("HEAD", &cmp)) { + if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) { struct diff_options opt; repo_diff_setup(repo, &opt); -- cgit v1.2.3 From bc726bd075929aab6b3e09d4dd5c2b0726fd5350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Mar 2023 15:58:50 +0200 Subject: cocci: apply the "object-store.h" part of "the_repository.pending" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the part of "the_repository.pending.cocci" pertaining to "object-store.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- read-cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index d6c69164d0..1548e88668 100644 --- a/read-cache.c +++ b/read-cache.c @@ -263,7 +263,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size) if (strbuf_readlink(&sb, ce->name, expected_size)) return -1; - buffer = read_object_file(&ce->oid, &type, &size); + buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size); if (buffer) { if (size == sb.len) match = memcmp(buffer, sb.buf, size); @@ -3553,7 +3553,8 @@ void *read_blob_data_from_index(struct index_state *istate, } if (pos < 0) return NULL; - data = read_object_file(&istate->cache[pos]->oid, &type, &sz); + data = repo_read_object_file(the_repository, &istate->cache[pos]->oid, + &type, &sz); if (!data || type != OBJ_BLOB) { free(data); return NULL; -- cgit v1.2.3 From 4a93b899c19794c28b140bf78a13fb9c2b34f433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Mar 2023 15:58:58 +0200 Subject: libs: use "struct repository *" argument, not "the_repository" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As can easily be seen from grepping in our sources, we had these uses of "the_repository" in various library code in cases where the function in question was already getting a "struct repository *" argument. Let's use that argument instead. Out of these changes only the changes to "cache-tree.c", "commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly applied before the migration away from the "repo_*()" wrapper macros in the preceding commits. The rest aren't new, as we'd previously implicitly refer to "the_repository", but it's now more obvious that we were doing the wrong thing all along, and should have used the parameter instead. The change to change "get_index_format_default(the_repository)" in "read-cache.c" to use the "r" variable instead should arguably have been part of [1], or in the subsequent cleanup in [2]. Let's do it here, as can be seen from the initial code in [3] it's not important that we use "the_repository" there, but would prefer to always use the current repository. This change excludes the "the_repository" use in "upload-pack.c"'s upload_pack_advertise(), as the in-flight [4] makes that change. 1. ee1f0c242ef (read-cache: add index.skipHash config option, 2023-01-06) 2. 6269f8eaad0 (treewide: always have a valid "index_state.repo" member, 2023-01-17) 3. 7211b9e7534 (repo-settings: consolidate some config settings, 2019-08-13) 4. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- read-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 1548e88668..892fede6b4 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo, if (tree) cmp = tree->object.oid; - if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) { + if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) { struct diff_options opt; repo_diff_setup(repo, &opt); @@ -2947,7 +2947,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, } if (!istate->version) - istate->version = get_index_format_default(the_repository); + istate->version = get_index_format_default(r); /* demote version 3 to version 2 when the latter suffices */ if (istate->version == 3 || istate->version == 2) -- cgit v1.2.3