Skip to content
Open
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
7 changes: 4 additions & 3 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,11 @@ const char *git_attr_system_file(void)

const char *git_attr_global_file(void)
{
if (!git_attributes_file)
git_attributes_file = xdg_config_home("attributes");
struct repo_config_values *cfg = repo_config_values(the_repository);
if (!cfg->attributes_file)
cfg->attributes_file = xdg_config_home("attributes");

return git_attributes_file;
return cfg->attributes_file;
}

int git_attr_system_is_enabled(void)
Expand Down
2 changes: 0 additions & 2 deletions branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ enum branch_track {
BRANCH_TRACK_SIMPLE,
};

extern enum branch_track git_branch_track;

/* Functions for acting on the information about branches. */

/**
Expand Down
3 changes: 2 additions & 1 deletion builtin/backfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
N_("Restrict the missing objects to the current sparse-checkout")),
OPT_END(),
};
struct repo_config_values *cfg = repo_config_values(the_repository);

show_usage_with_options_if_asked(argc, argv,
builtin_backfill_usage, options);
Expand All @@ -139,7 +140,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
repo_config(repo, git_default_config, NULL);

if (ctx.sparse < 0)
ctx.sparse = core_apply_sparse_checkout;
ctx.sparse = cfg->apply_sparse_checkout;

result = do_backfill(&ctx);
backfill_context_clear(&ctx);
Expand Down
3 changes: 2 additions & 1 deletion builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ int cmd_branch(int argc,
static struct ref_sorting *sorting;
struct string_list sorting_options = STRING_LIST_INIT_DUP;
struct ref_format format = REF_FORMAT_INIT;
struct repo_config_values *cfg = repo_config_values(the_repository);
int ret;

struct option options[] = {
Expand Down Expand Up @@ -795,7 +796,7 @@ int cmd_branch(int argc,
if (!sorting_options.nr)
string_list_append(&sorting_options, "refname");

track = git_branch_track;
track = cfg->branch_track;

head = refs_resolve_refdup(get_main_ref_store(the_repository), "HEAD",
0, &head_oid, NULL);
Expand Down
7 changes: 4 additions & 3 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ static int batch_objects(struct batch_options *opt)
struct strbuf input = STRBUF_INIT;
struct strbuf output = STRBUF_INIT;
struct expand_data data = EXPAND_DATA_INIT;
struct repo_config_values *cfg = repo_config_values(the_repository);
int save_warning;
int retval = 0;

Expand Down Expand Up @@ -947,8 +948,8 @@ static int batch_objects(struct batch_options *opt)
* warn) ends up dwarfing the actual cost of the object lookups
* themselves. We can work around it by just turning off the warning.
*/
save_warning = warn_on_object_refname_ambiguity;
warn_on_object_refname_ambiguity = 0;
save_warning = cfg->warn_on_object_refname_ambiguity;
cfg->warn_on_object_refname_ambiguity = 0;

if (opt->batch_mode == BATCH_MODE_QUEUE_AND_DISPATCH) {
batch_objects_command(opt, &output, &data);
Expand Down Expand Up @@ -976,7 +977,7 @@ static int batch_objects(struct batch_options *opt)
cleanup:
strbuf_release(&input);
strbuf_release(&output);
warn_on_object_refname_ambiguity = save_warning;
cfg->warn_on_object_refname_ambiguity = save_warning;
return retval;
}

Expand Down
3 changes: 2 additions & 1 deletion builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ static void die_if_switching_to_a_branch_in_use(struct checkout_opts *opts,
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new_branch_info)
{
struct repo_config_values *cfg = repo_config_values(the_repository);
int noop_switch = (!new_branch_info->name &&
!opts->new_branch &&
!opts->force_detach);
Expand Down Expand Up @@ -1633,7 +1634,7 @@ static int checkout_branch(struct checkout_opts *opts,
if (opts->track != BRANCH_TRACK_UNSPECIFIED)
die(_("'%s' cannot be used with '%s'"), "--detach", "-t");
} else if (opts->track == BRANCH_TRACK_UNSPECIFIED)
opts->track = git_branch_track;
opts->track = cfg->branch_track;

if (new_branch_info->name && !new_branch_info->commit)
die(_("Cannot switch branch to a non-commit '%s'"),
Expand Down
4 changes: 3 additions & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,15 @@ static int git_sparse_checkout_init(const char *repo)
{
struct child_process cmd = CHILD_PROCESS_INIT;
int result = 0;
struct repo_config_values *cfg = repo_config_values(the_repository);

strvec_pushl(&cmd.args, "-C", repo, "sparse-checkout", "set", NULL);

/*
* We must apply the setting in the current process
* for the later checkout to use the sparse-checkout file.
*/
core_apply_sparse_checkout = 1;
cfg->apply_sparse_checkout = 1;

cmd.git_cmd = 1;
if (run_command(&cmd)) {
Expand Down
8 changes: 5 additions & 3 deletions builtin/fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ static int store_object(
unsigned long hdrlen, deltalen;
struct git_hash_ctx c;
git_zstream s;
struct repo_config_values *cfg = repo_config_values(the_repository);

hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
dat->len);
Expand Down Expand Up @@ -1001,7 +1002,7 @@ static int store_object(
} else
delta = NULL;

git_deflate_init(&s, pack_compression_level);
git_deflate_init(&s, cfg->pack_compression_level);
if (delta) {
s.next_in = delta;
s.avail_in = deltalen;
Expand All @@ -1028,7 +1029,7 @@ static int store_object(
if (delta) {
FREE_AND_NULL(delta);

git_deflate_init(&s, pack_compression_level);
git_deflate_init(&s, cfg->pack_compression_level);
s.next_in = (void *)dat->buf;
s.avail_in = dat->len;
s.avail_out = git_deflate_bound(&s, s.avail_in);
Expand Down Expand Up @@ -1111,6 +1112,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
struct git_hash_ctx c;
git_zstream s;
struct hashfile_checkpoint checkpoint;
struct repo_config_values *cfg = repo_config_values(the_repository);
int status = Z_OK;

/* Determine if we should auto-checkpoint. */
Expand All @@ -1130,7 +1132,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)

crc32_begin(pack_file);

git_deflate_init(&s, pack_compression_level);
git_deflate_init(&s, cfg->pack_compression_level);

hdrlen = encode_in_pack_object_header(out_buf, out_sz, OBJ_BLOB, len);

Expand Down
2 changes: 1 addition & 1 deletion builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static int grep_submodule(struct grep_opt *opt,
* "forget" the sparse-index feature switch. As a result, the index
* of these submodules are expanded unexpectedly.
*
* 2. "core_apply_sparse_checkout"
* 2. "config_values_private_.apply_sparse_checkout"
* When running `grep` in the superproject, this setting is
* populated using the superproject's configs. However, once
* initialized, this config is globally accessible and is read by
Expand Down
3 changes: 2 additions & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,9 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)
git_zstream stream;
int status;
unsigned char outbuf[4096];
struct repo_config_values *cfg = repo_config_values(the_repository);

git_deflate_init(&stream, zlib_compression_level);
git_deflate_init(&stream, cfg->zlib_compression_level);
stream.next_in = in;
stream.avail_in = size;

Expand Down
5 changes: 3 additions & 2 deletions builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ int cmd_mv(int argc,
struct hashmap moved_dirs = HASHMAP_INIT(pathmap_cmp, NULL);
struct strbuf pathbuf = STRBUF_INIT;
int ret;
struct repo_config_values *cfg = repo_config_values(the_repository);

repo_config(the_repository, git_default_config, NULL);

Expand Down Expand Up @@ -572,8 +573,8 @@ int cmd_mv(int argc,
rename_index_entry_at(the_repository->index, pos, dst);

if (ignore_sparse &&
core_apply_sparse_checkout &&
core_sparse_checkout_cone) {
cfg->apply_sparse_checkout &&
cfg->core_sparse_checkout_cone) {
/*
* NEEDSWORK: we are *not* paying attention to
* "out-to-out" move (<source> is out-of-cone and
Expand Down
15 changes: 10 additions & 5 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ static unsigned long do_compress(void **pptr, unsigned long size)
git_zstream stream;
void *in, *out;
unsigned long maxsize;
struct repo_config_values *cfg = repo_config_values(the_repository);

git_deflate_init(&stream, pack_compression_level);
git_deflate_init(&stream, cfg->pack_compression_level);
maxsize = git_deflate_bound(&stream, size);

in = *pptr;
Expand All @@ -410,8 +411,9 @@ static unsigned long write_large_blob_data(struct odb_read_stream *st, struct ha
unsigned char ibuf[1024 * 16];
unsigned char obuf[1024 * 16];
unsigned long olen = 0;
struct repo_config_values *cfg = repo_config_values(the_repository);

git_deflate_init(&stream, pack_compression_level);
git_deflate_init(&stream, cfg->pack_compression_level);

for (;;) {
ssize_t readlen;
Expand Down Expand Up @@ -4659,6 +4661,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
struct setup_revision_opt s_r_opt = {
.allow_exclude_promisor_objects = 1,
};
struct repo_config_values *cfg = repo_config_values(the_repository);
char line[1000];
int flags = 0;
int save_warning;
Expand All @@ -4669,8 +4672,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
/* make sure shallows are read */
is_repository_shallow(the_repository);

save_warning = warn_on_object_refname_ambiguity;
warn_on_object_refname_ambiguity = 0;
save_warning = cfg->warn_on_object_refname_ambiguity;
cfg->warn_on_object_refname_ambiguity = 0;

while (fgets(line, sizeof(line), stdin) != NULL) {
int len = strlen(line);
Expand Down Expand Up @@ -4698,7 +4701,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
die(_("bad revision '%s'"), line);
}

warn_on_object_refname_ambiguity = save_warning;
cfg->warn_on_object_refname_ambiguity = save_warning;

if (use_bitmap_index && !get_object_list_from_bitmap(revs))
return;
Expand Down Expand Up @@ -4875,6 +4878,8 @@ int cmd_pack_objects(int argc,
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
struct list_objects_filter_options filter_options =
LIST_OBJECTS_FILTER_INIT;
struct repo_config_values *cfg = repo_config_values(the_repository);
int pack_compression_level = cfg->pack_compression_level;

struct option pack_objects_options[] = {
OPT_CALLBACK_F('q', "quiet", &progress, NULL,
Expand Down
3 changes: 2 additions & 1 deletion builtin/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static NORETURN void die_push_simple(struct branch *branch,
const char *advice_pushdefault_maybe = "";
const char *advice_automergesimple_maybe = "";
const char *short_upstream = branch->merge[0]->src;
struct repo_config_values *cfg = repo_config_values(the_repository);

skip_prefix(short_upstream, "refs/heads/", &short_upstream);

Expand All @@ -162,7 +163,7 @@ static NORETURN void die_push_simple(struct branch *branch,
advice_pushdefault_maybe = _("\n"
"To choose either option permanently, "
"see push.default in 'git help config'.\n");
if (git_branch_track != BRANCH_TRACK_SIMPLE)
if (cfg->branch_track != BRANCH_TRACK_SIMPLE)
advice_automergesimple_maybe = _("\n"
"To avoid automatically configuring "
"an upstream branch when its name\n"
Expand Down
Loading
Loading