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 --- object-name.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'object-name.c') diff --git a/object-name.c b/object-name.c index 2dd1a0f56e..21e8f67489 100644 --- a/object-name.c +++ b/object-name.c @@ -1666,7 +1666,8 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed) struct interpret_branch_name_options options = { .allowed = allowed }; - int used = interpret_branch_name(name, len, sb, &options); + int used = repo_interpret_branch_name(the_repository, name, len, sb, + &options); if (used < 0) used = 0; @@ -1719,7 +1720,7 @@ int get_oidf(struct object_id *oid, const char *fmt, ...) strbuf_vaddf(&sb, fmt, ap); va_end(ap); - ret = get_oid(sb.buf, oid); + ret = repo_get_oid(the_repository, sb.buf, oid); strbuf_release(&sb); return ret; -- cgit v1.2.3 From ecb5091fd4301ac647db0bd2504112b38f7ee06d 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:48 +0200 Subject: cocci: apply the "commit.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 "commit.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- object-name.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'object-name.c') diff --git a/object-name.c b/object-name.c index 21e8f67489..2926f26251 100644 --- a/object-name.c +++ b/object-name.c @@ -1036,7 +1036,7 @@ static enum get_oid_result get_parent(struct repository *r, if (ret) return ret; commit = lookup_commit_reference(r, &oid); - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) return MISSING_OBJECT; if (!idx) { oidcpy(result, &commit->object.oid); @@ -1070,7 +1070,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r, return MISSING_OBJECT; while (generation--) { - if (parse_commit(commit) || !commit->parents) + if (repo_parse_commit(the_repository, commit) || !commit->parents) return MISSING_OBJECT; commit = commit->parents->item; } @@ -1361,10 +1361,10 @@ static int get_oid_oneline(struct repository *r, commit = pop_most_recent_commit(&list, ONELINE_SEEN); if (!parse_object(r, &commit->object.oid)) continue; - buf = get_commit_buffer(commit, NULL); + buf = repo_get_commit_buffer(the_repository, commit, NULL); p = strstr(buf, "\n\n"); matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); - unuse_commit_buffer(commit, buf); + repo_unuse_commit_buffer(the_repository, commit, buf); if (matches) { oidcpy(oid, &commit->object.oid); -- cgit v1.2.3 From bab821646a74c446370fa8d01ca851f247df5033 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:51 +0200 Subject: cocci: apply the "pretty.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 "pretty.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- object-name.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'object-name.c') diff --git a/object-name.c b/object-name.c index 2926f26251..df31f192ce 100644 --- a/object-name.c +++ b/object-name.c @@ -394,8 +394,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) if (commit) { struct pretty_print_context pp = {0}; pp.date_mode.type = DATE_SHORT; - format_commit_message(commit, "%ad", &date, &pp); - format_commit_message(commit, "%s", &msg, &pp); + repo_format_commit_message(the_repository, commit, + "%ad", &date, &pp); + repo_format_commit_message(the_repository, commit, + "%s", &msg, &pp); } /* -- 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 --- object-name.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'object-name.c') diff --git a/object-name.c b/object-name.c index df31f192ce..c7bc311dce 100644 --- a/object-name.c +++ b/object-name.c @@ -1038,7 +1038,7 @@ static enum get_oid_result get_parent(struct repository *r, if (ret) return ret; commit = lookup_commit_reference(r, &oid); - if (repo_parse_commit(the_repository, commit)) + if (repo_parse_commit(r, commit)) return MISSING_OBJECT; if (!idx) { oidcpy(result, &commit->object.oid); @@ -1072,7 +1072,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r, return MISSING_OBJECT; while (generation--) { - if (repo_parse_commit(the_repository, commit) || !commit->parents) + if (repo_parse_commit(r, commit) || !commit->parents) return MISSING_OBJECT; commit = commit->parents->item; } @@ -1363,10 +1363,10 @@ static int get_oid_oneline(struct repository *r, commit = pop_most_recent_commit(&list, ONELINE_SEEN); if (!parse_object(r, &commit->object.oid)) continue; - buf = repo_get_commit_buffer(the_repository, commit, NULL); + buf = repo_get_commit_buffer(r, commit, NULL); p = strstr(buf, "\n\n"); matches = negative ^ (p && !regexec(®ex, p + 2, 0, NULL, 0)); - repo_unuse_commit_buffer(the_repository, commit, buf); + repo_unuse_commit_buffer(r, commit, buf); if (matches) { oidcpy(oid, &commit->object.oid); -- cgit v1.2.3