diff --git a/alloc.h b/alloc.h index ed1071c11ea3a6..abf65b47147591 100644 --- a/alloc.h +++ b/alloc.h @@ -5,7 +5,10 @@ struct alloc_state; struct tree; struct commit; struct tag; -struct repository; +struct repository +{ + int fetch_if_missing; +}repo; void *alloc_blob_node(struct repository *r); void *alloc_tree_node(struct repository *r); diff --git a/builtin/clone.c b/builtin/clone.c index f665b28ccccfac..2a0ffa7e54beba 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -33,6 +33,7 @@ #include "packfile.h" #include "list-objects-filter-options.h" #include "object-store.h" +#include "alloc.h" /* * Overall FIXMEs: @@ -928,7 +929,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) struct argv_array ref_prefixes = ARGV_ARRAY_INIT; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; packet_trace_identity("clone"); argc = parse_options(argc, argv, prefix, builtin_clone_options, @@ -1268,7 +1269,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) } junk_mode = JUNK_LEAVE_REPO; - fetch_if_missing = 1; + repo.fetch_if_missing = 1; err = checkout(submodule_progress); strbuf_release(&reflog_msg); diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index dc1485c8aa1bf2..2fe4433d8827bd 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -5,6 +5,7 @@ #include "connect.h" #include "sha1-array.h" #include "protocol.h" +#include "alloc.h" static const char fetch_pack_usage[] = "git fetch-pack [--all] [--stdin] [--quiet | -q] [--keep | -k] [--thin] " @@ -56,8 +57,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) struct string_list deepen_not = STRING_LIST_INIT_DUP; struct packet_reader reader; enum protocol_version version; - - fetch_if_missing = 0; + repo.fetch_if_missing = 0; packet_trace_identity("fetch-pack"); diff --git a/builtin/fetch.c b/builtin/fetch.c index 54d6b018929159..787a5e3a52fc97 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -24,6 +24,7 @@ #include "list-objects-filter-options.h" #include "commit-reach.h" #include "branch.h" +#include "alloc.h" #define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000) @@ -1675,7 +1676,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) packet_trace_identity("fetch"); - fetch_if_missing = 0; + repo.fetch_if_missing = 0; /* Record the command line for the reflog */ strbuf_addstr(&default_rla, "fetch"); diff --git a/builtin/fsck.c b/builtin/fsck.c index 18403a94fa4224..451ce0bd148245 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -21,6 +21,7 @@ #include "object-store.h" #include "run-command.h" #include "worktree.h" +#include "alloc.h" #define REACHABLE 0x0001 #define SEEN 0x0002 @@ -806,7 +807,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) struct object_directory *odb; /* fsck knows how to handle missing promisor objects */ - fetch_if_missing = 0; + repo.fetch_if_missing = 0; errors_found = 0; read_replace_refs = 0; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 0d55f73b0b443b..01b9f09b87ed85 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -15,6 +15,7 @@ #include "packfile.h" #include "object-store.h" #include "fetch-object.h" +#include "alloc.h" static const char index_pack_usage[] = "git index-pack [-v] [-o ] [--keep | --keep=] [--verify] [--strict] ( | --stdin [--fix-thin] [])"; @@ -1675,7 +1676,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) * accesses the repo to do hash collision checks and to check which * REF_DELTA bases need to be fetched. */ - fetch_if_missing = 0; + repo.fetch_if_missing = 0; if (argc == 2 && !strcmp(argv[1], "-h")) usage(index_pack_usage); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index b410801edb6b8a..18b58d8851ae01 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -34,6 +34,7 @@ #include "dir.h" #include "midx.h" #include "trace2.h" +#include "alloc.h" #define IN_PACK(obj) oe_in_pack(&to_pack, obj) #define SIZE(obj) oe_size(&to_pack, obj) @@ -2847,14 +2848,14 @@ static int option_parse_missing_action(const struct option *opt, if (!strcmp(arg, "allow-any")) { arg_missing_action = MA_ALLOW_ANY; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; fn_show_object = show_object__ma_allow_any; return 0; } if (!strcmp(arg, "allow-promisor")) { arg_missing_action = MA_ALLOW_PROMISOR; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; fn_show_object = show_object__ma_allow_promisor; return 0; } @@ -3396,7 +3397,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (exclude_promisor_objects) { use_internal_rev_list = 1; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; argv_array_push(&rp, "--exclude-promisor-objects"); } if (unpack_unreachable || keep_unreachable || pack_loose_unreachable) diff --git a/builtin/prune.c b/builtin/prune.c index 2b76872ad22078..bacbbce8886285 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -7,6 +7,7 @@ #include "parse-options.h" #include "progress.h" #include "object-store.h" +#include "alloc.h" static const char * const prune_usage[] = { N_("git prune [-n] [-v] [--progress] [--expire