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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2023-03-28 15:58:53 +02:00 committed by Junio C Hamano
parent afe27c8894
commit a5183d7696
18 changed files with 32 additions and 46 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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.
*/

View File

@ -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)

View File

@ -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)

View File

@ -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();

View File

@ -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");

View File

@ -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,

View File

@ -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

2
diff.c
View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/*

View File

@ -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) {

View File

@ -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 |

View File

@ -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

View File

@ -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.