From 5f139a1f40693f691fff41165e69e5514da87103 Mon Sep 17 00:00:00 2001 From: Shubham Ghule Date: Tue, 17 Sep 2019 23:48:57 +0530 Subject: [PATCH 1/3] changed fetch_if_missing from global to struct repo Signed-off-by: Shubham Ghule --- alloc.h | 5 ++++- builtin/fetch-pack.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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/fetch-pack.c b/builtin/fetch-pack.c index dc1485c8aa1bf2..a534076de90b5c 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -56,7 +56,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; - + repository r; fetch_if_missing = 0; packet_trace_identity("fetch-pack"); From ec833d950f88f17159735585e159f49fa2a507f3 Mon Sep 17 00:00:00 2001 From: Shubham Ghule Date: Tue, 17 Sep 2019 23:59:46 +0530 Subject: [PATCH 2/3] changed global to structure Signed-off-by: Shubham Ghule --- builtin/clone.c | 4 ++-- builtin/fetch-pack.c | 3 +-- builtin/fetch.c | 2 +- builtin/fsck.c | 2 +- builtin/index-pack.c | 2 +- builtin/pack-objects.c | 6 +++--- builtin/prune.c | 2 +- builtin/rev-list.c | 8 ++++---- cache.h | 2 +- fetch-object.c | 4 ++-- revision.c | 2 +- sha1-file.c | 4 ++-- 12 files changed, 20 insertions(+), 21 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index f665b28ccccfac..cfc70ef5c92a2f 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -928,7 +928,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 +1268,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 a534076de90b5c..a2cd87a78bc6e8 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -56,8 +56,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; - repository r; - 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..4f30be29943126 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1675,7 +1675,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..1fb83ad37b40eb 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -806,7 +806,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..4904d4ad52912a 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1675,7 +1675,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..eda39057b617c8 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2847,14 +2847,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 +3396,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..6e4db7c096c22f 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -165,7 +165,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix) if (show_progress == -1) show_progress = isatty(2); if (exclude_promisor_objects) { - fetch_if_missing = 0; + repo.fetch_if_missing = 0; revs.exclude_promisor_objects = 1; } diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 301ccb970bb363..c26b02f98a9743 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -346,19 +346,19 @@ static inline int parse_missing_action_value(const char *value) if (!strcmp(value, "allow-any")) { arg_missing_action = MA_ALLOW_ANY; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; return 1; } if (!strcmp(value, "print")) { arg_missing_action = MA_PRINT; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; return 1; } if (!strcmp(value, "allow-promisor")) { arg_missing_action = MA_ALLOW_PROMISOR; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; return 1; } @@ -400,7 +400,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (!strcmp(arg, "--exclude-promisor-objects")) { - fetch_if_missing = 0; + repo.fetch_if_missing = 0; revs.exclude_promisor_objects = 1; break; } diff --git a/cache.h b/cache.h index b1da1ab08faad3..5461aa3d061ebf 100644 --- a/cache.h +++ b/cache.h @@ -1669,7 +1669,7 @@ int odb_pack_keep(const char *name); * * Its default value is 1. */ -extern int fetch_if_missing; +//extern int fetch_if_missing; /* Dumb servers support */ int update_server_info(int); diff --git a/fetch-object.c b/fetch-object.c index 42665488008bc0..f76a414e8f2752 100644 --- a/fetch-object.c +++ b/fetch-object.c @@ -11,7 +11,7 @@ static void fetch_refs(const char *remote_name, struct ref *ref) struct transport *transport; int original_fetch_if_missing = fetch_if_missing; - fetch_if_missing = 0; + repo.fetch_if_missing = 0; remote = remote_get(remote_name); if (!remote->url[0]) die(_("Remote with no URL")); @@ -20,7 +20,7 @@ static void fetch_refs(const char *remote_name, struct ref *ref) transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1"); transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1"); transport_fetch_refs(transport, ref); - fetch_if_missing = original_fetch_if_missing; + repo.fetch_if_missing = original_fetch_if_missing; } void fetch_objects(const char *remote_name, const struct object_id *oids, diff --git a/revision.c b/revision.c index 51690e480d5b62..c255d117c7e639 100644 --- a/revision.c +++ b/revision.c @@ -2334,7 +2334,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->ignore_missing = 1; } else if (opt && opt->allow_exclude_promisor_objects && !strcmp(arg, "--exclude-promisor-objects")) { - if (fetch_if_missing) + if (repo.fetch_if_missing) BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0"); revs->exclude_promisor_objects = 1; } else { diff --git a/sha1-file.c b/sha1-file.c index 487ea35d2d3984..842323da3ea904 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1416,7 +1416,7 @@ static int loose_object_info(struct repository *r, return (status < 0) ? status : 0; } -int fetch_if_missing = 1; +repo.fetch_if_missing = 1; int oid_object_info_extended(struct repository *r, const struct object_id *oid, struct object_info *oi, unsigned flags) @@ -1475,7 +1475,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid, } /* Check if it is a missing object */ - if (fetch_if_missing && repository_format_partial_clone && + if (repo.fetch_if_missing && repository_format_partial_clone && !already_retried && r == the_repository && !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) { /* From 931ad3e7bfcb2c42a53ad9af53079e13a30240da Mon Sep 17 00:00:00 2001 From: Shubham Ghule Date: Sun, 22 Sep 2019 18:41:51 +0530 Subject: [PATCH 3/3] Changed the extern integer fetch_if_missing into the field of struct repository Signed-off-by: Shubham Ghule --- builtin/clone.c | 1 + builtin/fetch-pack.c | 1 + builtin/fetch.c | 1 + builtin/fsck.c | 1 + builtin/index-pack.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/rev-list.c | 1 + cache.h | 2 +- fetch-object.c | 1 + revision.c | 1 + sha1-file.c | 1 + 12 files changed, 12 insertions(+), 1 deletion(-) diff --git a/builtin/clone.c b/builtin/clone.c index cfc70ef5c92a2f..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: diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index a2cd87a78bc6e8..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] " diff --git a/builtin/fetch.c b/builtin/fetch.c index 4f30be29943126..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) diff --git a/builtin/fsck.c b/builtin/fsck.c index 1fb83ad37b40eb..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 diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 4904d4ad52912a..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] [])"; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index eda39057b617c8..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) diff --git a/builtin/prune.c b/builtin/prune.c index 6e4db7c096c22f..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