cocci: apply the "promisor-remote.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to "promisor-remote.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2023 at 15:58 UTC a5183d7696db34433ebcae64bad7609d5bb3a744
18 files changed +32 -46
builtin/cat-file.c
+1 -1
@@ -792,7 +792,7 @@ static int batch_objects(struct batch_options *opt)
792 if (!memcmp(&data.info, &empty, sizeof(empty)))
793 data.skip_object_info = 1;
794
795 - if (has_promisor_remote())
795 + if (repo_has_promisor_remote(the_repository))
796 warning("This repository uses promisor remotes. Some objects may not be loaded.");
797
798 read_replace_refs = 0;
builtin/fetch.c
+2 -2
@@ -2008,7 +2008,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
2008 * If no prior partial clone/fetch and the current fetch DID NOT
2009 * request a partial-fetch, do a normal fetch.
2010 */
2011 - if (!has_promisor_remote() && !filter_options.choice)
2011 + if (!repo_has_promisor_remote(the_repository) && !filter_options.choice)
2012 return;
2013
2014 /*
@@ -2264,7 +2264,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2264 printf("%s\n", oid_to_hex(oid));
2265 oidset_clear(&acked_commits);
2266 } else if (remote) {
2267 - if (filter_options.choice || has_promisor_remote())
2267 + if (filter_options.choice || repo_has_promisor_remote(the_repository))
2268 fetch_one_setup_partial(remote);
2269 result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs);
2270 } else {
builtin/gc.c
+1 -1
@@ -699,7 +699,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
699 strvec_push(&prune, prune_expire);
700 if (quiet)
701 strvec_push(&prune, "--no-progress");
702 - if (has_promisor_remote())
702 + if (repo_has_promisor_remote(the_repository))
703 strvec_push(&prune,
704 "--exclude-promisor-objects");
705 prune_cmd.git_cmd = 1;
builtin/index-pack.c
+1 -1
@@ -1390,7 +1390,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
1390 sorted_by_pos[i] = &ref_deltas[i];
1391 QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare);
1392
1393 - if (has_promisor_remote()) {
1393 + if (repo_has_promisor_remote(the_repository)) {
1394 /*
1395 * Prefetch the delta bases.
1396 */
builtin/pack-objects.c
+1 -1
@@ -2078,7 +2078,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
2078
2079 if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
2080 OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
2081 - if (has_promisor_remote()) {
2081 + if (repo_has_promisor_remote(the_repository)) {
2082 prefetch_to_pack(object_index);
2083 if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
2084 OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
builtin/repack.c
+1 -1
@@ -901,7 +901,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
901 strvec_push(&cmd.args, "--reflog");
902 strvec_push(&cmd.args, "--indexed-objects");
903 }
904 - if (has_promisor_remote())
904 + if (repo_has_promisor_remote(the_repository))
905 strvec_push(&cmd.args, "--exclude-promisor-objects");
906 if (!write_midx) {
907 if (write_bitmaps > 0)
cache-tree.c
+2 -2
@@ -240,7 +240,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
240
241 static int must_check_existence(const struct cache_entry *ce)
242 {
243 - return !(has_promisor_remote() && ce_skip_worktree(ce));
243 + return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
244 }
245
246 static int update_one(struct cache_tree *it,
@@ -470,7 +470,7 @@ int cache_tree_update(struct index_state *istate, int flags)
470 if (!istate->cache_tree)
471 istate->cache_tree = cache_tree();
472
473 - if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
473 + if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
474 prefetch_cache_entries(istate, must_check_existence);
475
476 trace_performance_enter();
connected.c
+2 -2
@@ -54,7 +54,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
54 strbuf_release(&idx_file);
55 }
56
57 - if (has_promisor_remote()) {
57 + if (repo_has_promisor_remote(the_repository)) {
58 /*
59 * For partial clones, we don't want to have to do a regular
60 * connectivity check because we have to enumerate and exclude
@@ -97,7 +97,7 @@ no_promisor_pack_found:
97 strvec_push(&rev_list.args,"rev-list");
98 strvec_push(&rev_list.args, "--objects");
99 strvec_push(&rev_list.args, "--stdin");
100 - if (has_promisor_remote())
100 + if (repo_has_promisor_remote(the_repository))
101 strvec_push(&rev_list.args, "--exclude-promisor-objects");
102 if (!opt->is_deepening_fetch) {
103 strvec_push(&rev_list.args, "--not");
contrib/coccinelle/the_repository.cocci
+10
@@ -95,6 +95,16 @@
95 |
96 - approximate_object_count
97 + repo_approximate_object_count
98 +// promisor-remote.h
99 +|
100 +- promisor_remote_reinit
101 ++ repo_promisor_remote_reinit
102 +|
103 +- promisor_remote_find
104 ++ repo_promisor_remote_find
105 +|
106 +- has_promisor_remote
107 ++ repo_has_promisor_remote
108 )
109 (
110 + the_repository,
contrib/coccinelle/the_repository.pending.cocci
-10
@@ -5,17 +5,7 @@
5 @@
6 @@
7 (
8 -// promisor-remote.h
9 -- promisor_remote_reinit
10 -+ repo_promisor_remote_reinit
11 -|
12 -- promisor_remote_find
13 -+ repo_promisor_remote_find
14 -|
15 -- has_promisor_remote
16 -+ repo_has_promisor_remote
8 // refs.h
18 -|
9 - dwim_ref
10 + repo_dwim_ref
11 // rerere.h
diff.c
+1 -1
@@ -6860,7 +6860,7 @@ void diffcore_std(struct diff_options *options)
6860 * If no prefetching occurs, diffcore_rename() will prefetch if it
6861 * decides that it needs inexact rename detection.
6862 */
6863 - if (options->repo == the_repository && has_promisor_remote() &&
6863 + if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&
6864 (options->output_format & output_formats_to_prefetch ||
6865 options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
6866 diff_queued_diff_prefetch(options->repo);
diffcore-break.c
+1 -1
@@ -65,7 +65,7 @@ static int should_break(struct repository *r,
65 oideq(&src->oid, &dst->oid))
66 return 0; /* they are the same */
67
68 - if (r == the_repository && has_promisor_remote()) {
68 + if (r == the_repository && repo_has_promisor_remote(the_repository)) {
69 options.missing_object_cb = diff_queued_diff_prefetch;
70 options.missing_object_data = r;
71 }
diffcore-rename.c
+2 -2
@@ -981,7 +981,7 @@ static int find_basename_matches(struct diff_options *options,
981 strintmap_set(&dests, base, i);
982 }
983
984 - if (options->repo == the_repository && has_promisor_remote()) {
984 + if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
985 dpf_options.missing_object_cb = basename_prefetch;
986 dpf_options.missing_object_data = &prefetch_options;
987 }
@@ -1567,7 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,
1567
1568 /* Finish setting up dpf_options */
1569 prefetch_options.skip_unmodified = skip_unmodified;
1570 - if (options->repo == the_repository && has_promisor_remote()) {
1570 + if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
1571 dpf_options.missing_object_cb = inexact_prefetch;
1572 dpf_options.missing_object_data = &prefetch_options;
1573 }
list-objects-filter-options.c
+4 -3
@@ -341,7 +341,7 @@ void partial_clone_register(
341 char *filter_name;
342
343 /* Check if it is already registered */
344 - if ((promisor_remote = promisor_remote_find(remote))) {
344 + if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {
345 if (promisor_remote->partial_clone_filter)
346 /*
347 * Remote is already registered and a filter is already
@@ -369,14 +369,15 @@ void partial_clone_register(
369 free(filter_name);
370
371 /* Make sure the config info are reset */
372 - promisor_remote_reinit();
372 + repo_promisor_remote_reinit(the_repository);
373 }
374
375 void partial_clone_get_default_filter_spec(
376 struct list_objects_filter_options *filter_options,
377 const char *remote)
378 {
379 - struct promisor_remote *promisor = promisor_remote_find(remote);
379 + struct promisor_remote *promisor = repo_promisor_remote_find(the_repository,
380 + remote);
381 struct strbuf errbuf = STRBUF_INIT;
382
383 /*
merge-ort.c
+1 -1
@@ -4216,7 +4216,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,
4216 struct string_list_item *e;
4217 struct oid_array to_fetch = OID_ARRAY_INIT;
4218
4219 - if (opt->repo != the_repository || !has_promisor_remote())
4219 + if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))
4220 return;
4221
4222 for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {
packfile.c
+1 -1
@@ -2263,7 +2263,7 @@ int is_promisor_object(const struct object_id *oid)
2263 static int promisor_objects_prepared;
2264
2265 if (!promisor_objects_prepared) {
2266 - if (has_promisor_remote()) {
2266 + if (repo_has_promisor_remote(the_repository)) {
2267 for_each_packed_object(add_promisor_object,
2268 &promisor_objects,
2269 FOR_EACH_OBJECT_PROMISOR_ONLY |
promisor-remote.h
-15
@@ -18,24 +18,9 @@ struct promisor_remote {
18 };
19
20 void repo_promisor_remote_reinit(struct repository *r);
21 -static inline void promisor_remote_reinit(void)
22 -{
23 - repo_promisor_remote_reinit(the_repository);
24 -}
25 -
21 void promisor_remote_clear(struct promisor_remote_config *config);
27 -
22 struct promisor_remote *repo_promisor_remote_find(struct repository *r, const char *remote_name);
29 -static inline struct promisor_remote *promisor_remote_find(const char *remote_name)
30 -{
31 - return repo_promisor_remote_find(the_repository, remote_name);
32 -}
33 -
23 int repo_has_promisor_remote(struct repository *r);
35 -static inline int has_promisor_remote(void)
36 -{
37 - return repo_has_promisor_remote(the_repository);
38 -}
24
25 /*
26 * Fetches all requested objects from all promisor remotes, trying them one at
unpack-trees.c
+1 -1
@@ -458,7 +458,7 @@ static int check_updates(struct unpack_trees_options *o,
458 if (should_update_submodules())
459 load_gitmodules_file(index, &state);
460
461 - if (has_promisor_remote())
461 + if (repo_has_promisor_remote(the_repository))
462 /*
463 * Prefetch the objects that are to be checked out in the loop
464 * below.