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 --- wt-status.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'wt-status.c') diff --git a/wt-status.c b/wt-status.c index 3162241a57..c55c51b192 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1337,7 +1337,7 @@ static void abbrev_oid_in_line(struct strbuf *line) * it after abbreviation. */ strbuf_trim(split[1]); - if (!get_oid(split[1]->buf, &oid)) { + if (!repo_get_oid(the_repository, split[1]->buf, &oid)) { strbuf_reset(split[1]); strbuf_add_unique_abbrev(split[1], &oid, DEFAULT_ABBREV); @@ -1503,8 +1503,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s, else status_printf_ln(s, color, _("You are currently cherry-picking commit %s."), - find_unique_abbrev(&s->state.cherry_pick_head_oid, - DEFAULT_ABBREV)); + repo_find_unique_abbrev(the_repository, &s->state.cherry_pick_head_oid, + DEFAULT_ABBREV)); if (s->hints) { if (has_unmerged(s)) @@ -1533,8 +1533,8 @@ static void show_revert_in_progress(struct wt_status *s, else status_printf_ln(s, color, _("You are currently reverting commit %s."), - find_unique_abbrev(&s->state.revert_head_oid, - DEFAULT_ABBREV)); + repo_find_unique_abbrev(the_repository, &s->state.revert_head_oid, + DEFAULT_ABBREV)); if (s->hints) { if (has_unmerged(s)) status_printf_ln(s, color, @@ -1676,9 +1676,9 @@ static void wt_status_get_detached_from(struct repository *r, state->detached_from = xstrdup(from); } else state->detached_from = - xstrdup(find_unique_abbrev(&cb.noid, DEFAULT_ABBREV)); + xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV)); oidcpy(&state->detached_oid, &cb.noid); - state->detached_at = !get_oid("HEAD", &oid) && + state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) && oideq(&oid, &state->detached_oid); free(ref); @@ -1769,13 +1769,13 @@ void wt_status_get_state(struct repository *r, } else if (wt_status_check_rebase(NULL, state)) { ; /* all set */ } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && - !get_oid("CHERRY_PICK_HEAD", &oid)) { + !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) { state->cherry_pick_in_progress = 1; oidcpy(&state->cherry_pick_head_oid, &oid); } wt_status_check_bisect(NULL, state); if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") && - !get_oid("REVERT_HEAD", &oid)) { + !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) { state->revert_in_progress = 1; oidcpy(&state->revert_head_oid, &oid); } -- cgit v1.2.3 From 12cb1c10a64170a5d600dd1c6c8abfeec105fb6b 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:54 +0200 Subject: cocci: apply the "refs.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 "refs.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- wt-status.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'wt-status.c') diff --git a/wt-status.c b/wt-status.c index c55c51b192..dcd1d0cee4 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1664,7 +1664,8 @@ static void wt_status_get_detached_from(struct repository *r, return; } - if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 && + if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref, + 1) == 1 && /* oid is a commit? match without further lookup */ (oideq(&cb.noid, &oid) || /* perhaps oid is a tag, try to dereference to a commit */ -- 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 --- wt-status.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'wt-status.c') diff --git a/wt-status.c b/wt-status.c index dcd1d0cee4..28e35a2165 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1664,7 +1664,7 @@ static void wt_status_get_detached_from(struct repository *r, return; } - if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref, + if (repo_dwim_ref(r, cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 && /* oid is a commit? match without further lookup */ (oideq(&cb.noid, &oid) || @@ -1677,9 +1677,9 @@ static void wt_status_get_detached_from(struct repository *r, state->detached_from = xstrdup(from); } else state->detached_from = - xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV)); + xstrdup(repo_find_unique_abbrev(r, &cb.noid, DEFAULT_ABBREV)); oidcpy(&state->detached_oid, &cb.noid); - state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) && + state->detached_at = !repo_get_oid(r, "HEAD", &oid) && oideq(&oid, &state->detached_oid); free(ref); @@ -1770,13 +1770,13 @@ void wt_status_get_state(struct repository *r, } else if (wt_status_check_rebase(NULL, state)) { ; /* all set */ } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && - !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) { + !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) { state->cherry_pick_in_progress = 1; oidcpy(&state->cherry_pick_head_oid, &oid); } wt_status_check_bisect(NULL, state); if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") && - !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) { + !repo_get_oid(r, "REVERT_HEAD", &oid)) { state->revert_in_progress = 1; oidcpy(&state->revert_head_oid, &oid); } -- cgit v1.2.3