Skip to content
Merged
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
11 changes: 10 additions & 1 deletion Documentation/RelNotes/2.54.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ Performance, Internal Implementation, Development Support etc.
* Clean-up the code around "git repo info" command.
* Mark the marge-ort codebase to prevent more uses of the_repository
* Mark the merge-ort codebase to prevent more uses of the_repository
from getting added.
* The core.attributesfile is intended to be set per repository, but
were kept track of by a single global variable in-core, which has
been corrected by moving it to per-repository data structure.
Fixes since v2.53
-----------------
Expand Down Expand Up @@ -225,6 +229,11 @@ Fixes since v2.53
corrected.
(merge 3ef68ff40e sp/shallow-deepen-relative-fix later to maint).

* "fsck" iterates over packfiles and its access to pack data caused
the list to be permuted, which caused it to loop forever; the code
to access pack data by "fsck" has been updated to avoid this.
(merge 13eb65d366 ps/fsck-stream-from-the-right-object-instance later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).
(merge 7a747f972d dd/t5403-modernise later to maint).
Expand Down
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 @@ -128,6 +128,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 @@ -138,7 +139,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
3 changes: 2 additions & 1 deletion builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,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 @@ -1646,7 +1647,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 @@ -616,13 +616,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
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/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,7 +573,7 @@ int cmd_mv(int argc,
rename_index_entry_at(the_repository->index, pos, dst);

if (ignore_sparse &&
core_apply_sparse_checkout &&
cfg->apply_sparse_checkout &&
core_sparse_checkout_cone) {
/*
* NEEDSWORK: we are *not* paying attention to
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
31 changes: 20 additions & 11 deletions builtin/sparse-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
struct pattern_list pl;
char *sparse_filename;
int res;
struct repo_config_values *cfg = repo_config_values(the_repository);

setup_work_tree();
if (!core_apply_sparse_checkout)
if (!cfg->apply_sparse_checkout)
die(_("this worktree is not sparse"));

argc = parse_options(argc, argv, prefix,
Expand Down Expand Up @@ -397,12 +398,14 @@ static int set_config(struct repository *repo,
}

static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
struct repo_config_values *cfg = repo_config_values(the_repository);

/* If not specified, use previous definition of cone mode */
if (*cone_mode == -1 && core_apply_sparse_checkout)
if (*cone_mode == -1 && cfg->apply_sparse_checkout)
*cone_mode = core_sparse_checkout_cone;

/* Set cone/non-cone mode appropriately */
core_apply_sparse_checkout = 1;
cfg->apply_sparse_checkout = 1;
if (*cone_mode == 1 || *cone_mode == -1) {
core_sparse_checkout_cone = 1;
return MODE_CONE_PATTERNS;
Expand All @@ -414,9 +417,10 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
static int update_modes(struct repository *repo, int *cone_mode, int *sparse_index)
{
int mode, record_mode;
struct repo_config_values *cfg = repo_config_values(the_repository);

/* Determine if we need to record the mode; ensure sparse checkout on */
record_mode = (*cone_mode != -1) || !core_apply_sparse_checkout;
record_mode = (*cone_mode != -1) || !cfg->apply_sparse_checkout;

mode = update_cone_mode(cone_mode);
if (record_mode && set_config(repo, mode))
Expand Down Expand Up @@ -682,6 +686,7 @@ static int modify_pattern_list(struct repository *repo,
int result;
int changed_config = 0;
struct pattern_list *pl = xcalloc(1, sizeof(*pl));
struct repo_config_values *cfg = repo_config_values(the_repository);

switch (m) {
case ADD:
Expand All @@ -697,9 +702,9 @@ static int modify_pattern_list(struct repository *repo,
break;
}

if (!core_apply_sparse_checkout) {
if (!cfg->apply_sparse_checkout) {
set_config(repo, MODE_ALL_PATTERNS);
core_apply_sparse_checkout = 1;
cfg->apply_sparse_checkout = 1;
changed_config = 1;
}

Expand Down Expand Up @@ -794,9 +799,10 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
};
struct strvec patterns = STRVEC_INIT;
int ret;
struct repo_config_values *cfg = repo_config_values(the_repository);

setup_work_tree();
if (!core_apply_sparse_checkout)
if (!cfg->apply_sparse_checkout)
die(_("no sparse-checkout to add to"));

repo_read_index(repo);
Expand Down Expand Up @@ -903,9 +909,10 @@ static int sparse_checkout_reapply(int argc, const char **argv,
N_("toggle the use of a sparse index")),
OPT_END(),
};
struct repo_config_values *cfg = repo_config_values(the_repository);

setup_work_tree();
if (!core_apply_sparse_checkout)
if (!cfg->apply_sparse_checkout)
die(_("must be in a sparse-checkout to reapply sparsity patterns"));

reapply_opts.cone_mode = -1;
Expand Down Expand Up @@ -958,6 +965,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
size_t worktree_len;
int force = 0, dry_run = 0, verbose = 0;
int require_force = 1;
struct repo_config_values *cfg = repo_config_values(the_repository);

struct option builtin_sparse_checkout_clean_options[] = {
OPT__DRY_RUN(&dry_run, N_("dry run")),
Expand All @@ -967,7 +975,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
};

setup_work_tree();
if (!core_apply_sparse_checkout)
if (!cfg->apply_sparse_checkout)
die(_("must be in a sparse-checkout to clean directories"));
if (!core_sparse_checkout_cone)
die(_("must be in a cone-mode sparse-checkout to clean directories"));
Expand Down Expand Up @@ -1031,9 +1039,10 @@ static int sparse_checkout_disable(int argc, const char **argv,
OPT_END(),
};
struct pattern_list pl;
struct repo_config_values *cfg = repo_config_values(the_repository);

/*
* We do not exit early if !core_apply_sparse_checkout; due to the
* We do not exit early if !repo->config_values.apply_sparse_checkout; due to the
* ability for users to manually muck things up between
* direct editing of .git/info/sparse-checkout
* running read-tree -m u HEAD or update-index --skip-worktree
Expand All @@ -1059,7 +1068,7 @@ static int sparse_checkout_disable(int argc, const char **argv,
hashmap_init(&pl.recursive_hashmap, pl_hashmap_cmp, NULL, 0);
hashmap_init(&pl.parent_hashmap, pl_hashmap_cmp, NULL, 0);
pl.use_cone_patterns = 0;
core_apply_sparse_checkout = 1;
cfg->apply_sparse_checkout = 1;

add_pattern("/*", empty_base, 0, &pl, 0);

Expand Down
3 changes: 2 additions & 1 deletion builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3300,9 +3300,10 @@ static int module_create_branch(int argc, const char **argv, const char *prefix,
N_("git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>"),
NULL
};
struct repo_config_values *cfg = repo_config_values(the_repository);

repo_config(the_repository, git_default_config, NULL);
track = git_branch_track;
track = cfg->branch_track;
argc = parse_options(argc, argv, prefix, options, usage, 0);

if (argc != 3)
Expand Down
3 changes: 2 additions & 1 deletion builtin/worktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ static int add_worktree(const char *path, const char *refname,
struct strbuf sb_name = STRBUF_INIT;
struct worktree **worktrees, *wt = NULL;
struct ref_store *wt_refs;
struct repo_config_values *cfg = repo_config_values(the_repository);

worktrees = get_worktrees();
check_candidate_path(path, opts->force, worktrees, "add");
Expand Down Expand Up @@ -570,7 +571,7 @@ static int add_worktree(const char *path, const char *refname,
* If the current worktree has sparse-checkout enabled, then copy
* the sparse-checkout patterns from the current worktree.
*/
if (core_apply_sparse_checkout)
if (cfg->apply_sparse_checkout)
copy_sparse_checkout(sb_repo.buf);

/*
Expand Down
4 changes: 3 additions & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,9 @@ enum pattern_match_result path_matches_pattern_list(

int init_sparse_checkout_patterns(struct index_state *istate)
{
if (!core_apply_sparse_checkout)
struct repo_config_values *cfg = repo_config_values(the_repository);

if (!cfg->apply_sparse_checkout)
return 1;
if (istate->sparse_checkout_patterns)
return 0;
Expand Down
Loading