From a5183d7696db34433ebcae64bad7609d5bb3a744 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:53 +0200 Subject: [PATCH] cocci: apply the "promisor-remote.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 "promisor-remote.h". Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/cat-file.c | 2 +- builtin/fetch.c | 4 ++-- builtin/gc.c | 2 +- builtin/index-pack.c | 2 +- builtin/pack-objects.c | 2 +- builtin/repack.c | 2 +- cache-tree.c | 4 ++-- connected.c | 4 ++-- contrib/coccinelle/the_repository.cocci | 10 ++++++++++ contrib/coccinelle/the_repository.pending.cocci | 10 ---------- diff.c | 2 +- diffcore-break.c | 2 +- diffcore-rename.c | 4 ++-- list-objects-filter-options.c | 7 ++++--- merge-ort.c | 2 +- packfile.c | 2 +- promisor-remote.h | 15 --------------- unpack-trees.c | 2 +- 18 files changed, 32 insertions(+), 46 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index caf2d25861..b72dd91bd1 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -792,7 +792,7 @@ static int batch_objects(struct batch_options *opt) if (!memcmp(&data.info, &empty, sizeof(empty))) data.skip_object_info = 1; - if (has_promisor_remote()) + if (repo_has_promisor_remote(the_repository)) warning("This repository uses promisor remotes. Some objects may not be loaded."); read_replace_refs = 0; diff --git a/builtin/fetch.c b/builtin/fetch.c index 784e344d2b..0020015ca4 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2008,7 +2008,7 @@ static inline void fetch_one_setup_partial(struct remote *remote) * If no prior partial clone/fetch and the current fetch DID NOT * request a partial-fetch, do a normal fetch. */ - if (!has_promisor_remote() && !filter_options.choice) + if (!repo_has_promisor_remote(the_repository) && !filter_options.choice) return; /* @@ -2264,7 +2264,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) printf("%s\n", oid_to_hex(oid)); oidset_clear(&acked_commits); } else if (remote) { - if (filter_options.choice || has_promisor_remote()) + if (filter_options.choice || repo_has_promisor_remote(the_repository)) fetch_one_setup_partial(remote); result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs); } else { diff --git a/builtin/gc.c b/builtin/gc.c index bef26020f9..a1a2ae4da2 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -699,7 +699,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix) strvec_push(&prune, prune_expire); if (quiet) strvec_push(&prune, "--no-progress"); - if (has_promisor_remote()) + if (repo_has_promisor_remote(the_repository)) strvec_push(&prune, "--exclude-promisor-objects"); prune_cmd.git_cmd = 1; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 4cf69ee1d9..de47f3f644 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1390,7 +1390,7 @@ static void fix_unresolved_deltas(struct hashfile *f) sorted_by_pos[i] = &ref_deltas[i]; QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare); - if (has_promisor_remote()) { + if (repo_has_promisor_remote(the_repository)) { /* * Prefetch the delta bases. */ diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 3c9b35642c..2f2c02589b 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2078,7 +2078,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index) if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) { - if (has_promisor_remote()) { + if (repo_has_promisor_remote(the_repository)) { prefetch_to_pack(object_index); if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) diff --git a/builtin/repack.c b/builtin/repack.c index f649379531..25658fe732 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -901,7 +901,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) strvec_push(&cmd.args, "--reflog"); strvec_push(&cmd.args, "--indexed-objects"); } - if (has_promisor_remote()) + if (repo_has_promisor_remote(the_repository)) strvec_push(&cmd.args, "--exclude-promisor-objects"); if (!write_midx) { if (write_bitmaps > 0) diff --git a/cache-tree.c b/cache-tree.c index 59610117d0..ab2cc1edf2 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -240,7 +240,7 @@ int cache_tree_fully_valid(struct cache_tree *it) static int must_check_existence(const struct cache_entry *ce) { - return !(has_promisor_remote() && ce_skip_worktree(ce)); + return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce)); } static int update_one(struct cache_tree *it, @@ -470,7 +470,7 @@ int cache_tree_update(struct index_state *istate, int flags) if (!istate->cache_tree) istate->cache_tree = cache_tree(); - if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote()) + if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository)) prefetch_cache_entries(istate, must_check_existence); trace_performance_enter(); diff --git a/connected.c b/connected.c index b90fd61790..5853fd7cbf 100644 --- a/connected.c +++ b/connected.c @@ -54,7 +54,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, strbuf_release(&idx_file); } - if (has_promisor_remote()) { + if (repo_has_promisor_remote(the_repository)) { /* * For partial clones, we don't want to have to do a regular * connectivity check because we have to enumerate and exclude @@ -97,7 +97,7 @@ no_promisor_pack_found: strvec_push(&rev_list.args,"rev-list"); strvec_push(&rev_list.args, "--objects"); strvec_push(&rev_list.args, "--stdin"); - if (has_promisor_remote()) + if (repo_has_promisor_remote(the_repository)) strvec_push(&rev_list.args, "--exclude-promisor-objects"); if (!opt->is_deepening_fetch) { strvec_push(&rev_list.args, "--not"); diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci index a325361f96..d5b644a868 100644 --- a/contrib/coccinelle/the_repository.cocci +++ b/contrib/coccinelle/the_repository.cocci @@ -95,6 +95,16 @@ | - approximate_object_count + repo_approximate_object_count +// promisor-remote.h +| +- promisor_remote_reinit ++ repo_promisor_remote_reinit +| +- promisor_remote_find ++ repo_promisor_remote_find +| +- has_promisor_remote ++ repo_has_promisor_remote ) ( + the_repository, diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci index 9b426e49e6..e17a60198c 100644 --- a/contrib/coccinelle/the_repository.pending.cocci +++ b/contrib/coccinelle/the_repository.pending.cocci @@ -5,17 +5,7 @@ @@ @@ ( -// promisor-remote.h -- promisor_remote_reinit -+ repo_promisor_remote_reinit -| -- promisor_remote_find -+ repo_promisor_remote_find -| -- has_promisor_remote -+ repo_has_promisor_remote // refs.h -| - dwim_ref + repo_dwim_ref // rerere.h diff --git a/diff.c b/diff.c index 3abeca9d46..5278343f95 100644 --- a/diff.c +++ b/diff.c @@ -6860,7 +6860,7 @@ void diffcore_std(struct diff_options *options) * If no prefetching occurs, diffcore_rename() will prefetch if it * decides that it needs inexact rename detection. */ - if (options->repo == the_repository && has_promisor_remote() && + if (options->repo == the_repository && repo_has_promisor_remote(the_repository) && (options->output_format & output_formats_to_prefetch || options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)) diff_queued_diff_prefetch(options->repo); diff --git a/diffcore-break.c b/diffcore-break.c index 0d4a14964d..5462420bbb 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -65,7 +65,7 @@ static int should_break(struct repository *r, oideq(&src->oid, &dst->oid)) return 0; /* they are the same */ - if (r == the_repository && has_promisor_remote()) { + if (r == the_repository && repo_has_promisor_remote(the_repository)) { options.missing_object_cb = diff_queued_diff_prefetch; options.missing_object_data = r; } diff --git a/diffcore-rename.c b/diffcore-rename.c index c0422d9e70..a97b1322b5 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -981,7 +981,7 @@ static int find_basename_matches(struct diff_options *options, strintmap_set(&dests, base, i); } - if (options->repo == the_repository && has_promisor_remote()) { + if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) { dpf_options.missing_object_cb = basename_prefetch; dpf_options.missing_object_data = &prefetch_options; } @@ -1567,7 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options, /* Finish setting up dpf_options */ prefetch_options.skip_unmodified = skip_unmodified; - if (options->repo == the_repository && has_promisor_remote()) { + if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) { dpf_options.missing_object_cb = inexact_prefetch; dpf_options.missing_object_data = &prefetch_options; } diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index ee01bcd2cc..ccfeabc477 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -341,7 +341,7 @@ void partial_clone_register( char *filter_name; /* Check if it is already registered */ - if ((promisor_remote = promisor_remote_find(remote))) { + if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) { if (promisor_remote->partial_clone_filter) /* * Remote is already registered and a filter is already @@ -369,14 +369,15 @@ void partial_clone_register( free(filter_name); /* Make sure the config info are reset */ - promisor_remote_reinit(); + repo_promisor_remote_reinit(the_repository); } void partial_clone_get_default_filter_spec( struct list_objects_filter_options *filter_options, const char *remote) { - struct promisor_remote *promisor = promisor_remote_find(remote); + struct promisor_remote *promisor = repo_promisor_remote_find(the_repository, + remote); struct strbuf errbuf = STRBUF_INIT; /* diff --git a/merge-ort.c b/merge-ort.c index 979e8b057b..ba3f5607bb 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4216,7 +4216,7 @@ static void prefetch_for_content_merges(struct merge_options *opt, struct string_list_item *e; struct oid_array to_fetch = OID_ARRAY_INIT; - if (opt->repo != the_repository || !has_promisor_remote()) + if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository)) return; for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) { diff --git a/packfile.c b/packfile.c index 79e21ab18e..4aee73d545 100644 --- a/packfile.c +++ b/packfile.c @@ -2263,7 +2263,7 @@ int is_promisor_object(const struct object_id *oid) static int promisor_objects_prepared; if (!promisor_objects_prepared) { - if (has_promisor_remote()) { + if (repo_has_promisor_remote(the_repository)) { for_each_packed_object(add_promisor_object, &promisor_objects, FOR_EACH_OBJECT_PROMISOR_ONLY | diff --git a/promisor-remote.h b/promisor-remote.h index df36eb08ef..2cb9eda9ea 100644 --- a/promisor-remote.h +++ b/promisor-remote.h @@ -18,24 +18,9 @@ struct promisor_remote { }; void repo_promisor_remote_reinit(struct repository *r); -static inline void promisor_remote_reinit(void) -{ - repo_promisor_remote_reinit(the_repository); -} - void promisor_remote_clear(struct promisor_remote_config *config); - struct promisor_remote *repo_promisor_remote_find(struct repository *r, const char *remote_name); -static inline struct promisor_remote *promisor_remote_find(const char *remote_name) -{ - return repo_promisor_remote_find(the_repository, remote_name); -} - int repo_has_promisor_remote(struct repository *r); -static inline int has_promisor_remote(void) -{ - return repo_has_promisor_remote(the_repository); -} /* * Fetches all requested objects from all promisor remotes, trying them one at diff --git a/unpack-trees.c b/unpack-trees.c index 3d05e45a27..b82ad7e45d 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -458,7 +458,7 @@ static int check_updates(struct unpack_trees_options *o, if (should_update_submodules()) load_gitmodules_file(index, &state); - if (has_promisor_remote()) + if (repo_has_promisor_remote(the_repository)) /* * Prefetch the objects that are to be checked out in the loop * below.