Skip to content

Turned fetch_if_mising into field of struct repository #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "packfile.h"
#include "list-objects-filter-options.h"
#include "object-store.h"
#include "alloc.h"

/*
* Overall FIXMEs:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] "
Expand Down Expand Up @@ -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");

Expand Down
3 changes: 2 additions & 1 deletion builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "object-store.h"
#include "run-command.h"
#include "worktree.h"
#include "alloc.h"

#define REACHABLE 0x0001
#define SEEN 0x0002
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion builtin/prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <time>] [--] [<head>...]"),
Expand Down Expand Up @@ -165,7 +166,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;
}

Expand Down
9 changes: 5 additions & 4 deletions builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "oidset.h"
#include "packfile.h"
#include "object-store.h"
#include "alloc.h"

static const char rev_list_usage[] =
"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
Expand Down Expand Up @@ -346,19 +347,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;
}

Expand Down Expand Up @@ -400,7 +401,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;
}
Expand Down
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 is now a field of structure repository */

/* Dumb servers support */
int update_server_info(int);
Expand Down
5 changes: 3 additions & 2 deletions fetch-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include "strbuf.h"
#include "transport.h"
#include "fetch-object.h"
#include "alloc.h"

static void fetch_refs(const char *remote_name, struct ref *ref)
{
struct remote *remote;
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"));
Expand All @@ -20,7 +21,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,
Expand Down
3 changes: 2 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "commit-graph.h"
#include "prio-queue.h"
#include "hashmap.h"
#include "alloc.h"

volatile show_early_output_fn_t show_early_output;

Expand Down Expand Up @@ -2334,7 +2335,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 {
Expand Down
5 changes: 3 additions & 2 deletions sha1-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "packfile.h"
#include "fetch-object.h"
#include "object-store.h"
#include "alloc.h"

/* The maximum size for an object header. */
#define MAX_HEADER_LEN 32
Expand Down Expand Up @@ -1416,7 +1417,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)
Expand Down Expand Up @@ -1475,7 +1476,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)) {
/*
Expand Down