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
6 changes: 3 additions & 3 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ static int parse_mail(struct am_state *state, const char *mail)
setup_mailinfo(the_repository, &mi);

if (state->utf8)
mi.metainfo_charset = get_commit_output_encoding();
mi.metainfo_charset = get_commit_output_encoding(the_repository);
else
mi.metainfo_charset = NULL;

Expand Down Expand Up @@ -1355,7 +1355,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
struct ident_split id;

buffer = repo_logmsg_reencode(the_repository, commit, NULL,
get_commit_output_encoding());
get_commit_output_encoding(the_repository));

ident_line = find_commit_header(buffer, "author", &ident_len);
if (!ident_line)
Expand Down Expand Up @@ -1699,7 +1699,7 @@ static void do_commit(const struct am_state *state)
: state->author_date,
IDENT_STRICT);

if (commit_tree_extended(state->msg, state->msg_len, &tree, parents,
if (commit_tree_extended(the_repository, state->msg, state->msg_len, &tree, parents,
&commit, author, committer, state->sign_commit,
NULL))
die(_("failed to write commit object"));
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
2 changes: 1 addition & 1 deletion builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void get_commit_info(struct commit *commit, struct commit_info *ret)
const char *subject, *encoding;
const char *message;

encoding = get_log_output_encoding();
encoding = get_log_output_encoding(the_repository);
message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
get_ac_line(message, "\nauthor ",
&ret->author, &ret->author_mail,
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/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
struct strbuf sb = STRBUF_INIT;

if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &sb);
if (print_sha1_ellipsis()) {
fprintf(stderr, "%s %s... %s\n", msg,
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
Expand Down Expand Up @@ -1077,7 +1077,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
strbuf_addch(sb, ' ');
if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, sb);
strbuf_addch(sb, '\n');
}

Expand Down 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
2 changes: 1 addition & 1 deletion builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int cmd_commit_tree(int argc,
die_errno(_("git commit-tree: failed to read"));
}

if (commit_tree(buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
if (commit_tree(the_repository, buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
NULL, sign_commit)) {
ret = 1;
goto out;
Expand Down
8 changes: 4 additions & 4 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
c = lookup_commit_reference_by_name(squash_message);
if (!c)
die(_("could not lookup commit '%s'"), squash_message);
ctx.output_encoding = get_commit_output_encoding();
ctx.output_encoding = get_commit_output_encoding(the_repository);
repo_format_commit_message(the_repository, c,
"squash! %s\n\n", &sb,
&ctx);
Expand Down Expand Up @@ -829,7 +829,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
commit = lookup_commit_reference_by_name(fixup_commit);
if (!commit)
die(_("could not lookup commit '%s'"), fixup_commit);
ctx.output_encoding = get_commit_output_encoding();
ctx.output_encoding = get_commit_output_encoding(the_repository);
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
repo_format_commit_message(the_repository, commit, fmt, &sb,
&ctx);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ static const char *read_commit_message(const char *name)
commit = lookup_commit_reference_by_name(name);
if (!commit)
die(_("could not lookup commit '%s'"), name);
out_enc = get_commit_output_encoding();
out_enc = get_commit_output_encoding(the_repository);
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
}

Expand Down Expand Up @@ -1931,7 +1931,7 @@ int cmd_commit(int argc,
append_merge_tag_headers(parents, &tail);
}

if (commit_tree_extended(sb.buf, sb.len, &the_repository->index->cache_tree->oid,
if (commit_tree_extended(the_repository, sb.buf, sb.len, &the_repository->index->cache_tree->oid,
parents, &oid, author_ident.buf, NULL,
sign_commit, extra)) {
rollback_index_files();
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
2 changes: 1 addition & 1 deletion builtin/history.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static int commit_tree_with_edited_message(struct repository *repo,

original_extra_headers = read_commit_extra_headers(original, exclude_gpgsig);

ret = commit_tree_extended(commit_message.buf, commit_message.len, &original_tree_oid,
ret = commit_tree_extended(repo, commit_message.buf, commit_message.len, &original_tree_oid,
original->parents, &rewritten_commit_oid, original_author,
NULL, NULL, original_extra_headers);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ static void show_tagger(const char *buf, struct rev_info *rev)

pp.fmt = rev->commit_format;
pp.date_mode = rev->date_mode;
pp_user_info(&pp, "Tagger", &out, buf, get_log_output_encoding());
pp_user_info(&pp, "Tagger", &out, buf, get_log_output_encoding(the_repository));
fprintf(rev->diffopt.file, "%s", out.buf);
strbuf_release(&out);
}
Expand Down Expand Up @@ -2521,7 +2521,7 @@ static void print_commit(char sign, struct commit *commit, int verbose,
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &buf);
fprintf(file, "%c %s %s\n", sign,
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
buf.buf);
Expand Down
6 changes: 3 additions & 3 deletions builtin/mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int parse_opt_quoted_cr(const struct option *opt, const char *arg, int un
int cmd_mailinfo(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
struct metainfo_charset meta_charset;
struct mailinfo mi;
Expand Down Expand Up @@ -83,7 +83,7 @@ int cmd_mailinfo(int argc,
OPT_END()
};

setup_mailinfo(the_repository, &mi);
setup_mailinfo(repo, &mi);
meta_charset.policy = CHARSET_DEFAULT;

argc = parse_options(argc, argv, prefix, options, mailinfo_usage, 0);
Expand All @@ -93,7 +93,7 @@ int cmd_mailinfo(int argc,

switch (meta_charset.policy) {
case CHARSET_DEFAULT:
mi.metainfo_charset = get_commit_output_encoding();
mi.metainfo_charset = get_commit_output_encoding(repo);
break;
case CHARSET_NO_REENCODE:
mi.metainfo_charset = NULL;
Expand Down
6 changes: 3 additions & 3 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
oid_to_hex(&commit->object.oid));
pretty_print_commit(&ctx, commit, &out);
pretty_print_commit(the_repository, &ctx, commit, &out);
}
write_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);
strbuf_release(&out);
Expand Down Expand Up @@ -1000,7 +1000,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
pptr = commit_list_append(head, pptr);
pptr = commit_list_append(remoteheads->item, pptr);
prepare_to_commit(remoteheads);
if (commit_tree(merge_msg.buf, merge_msg.len, &result_tree, parents,
if (commit_tree(the_repository, merge_msg.buf, merge_msg.len, &result_tree, parents,
&result_commit, NULL, sign_commit))
die(_("failed to write commit object"));
finish(head, remoteheads, &result_commit, "In-index merge");
Expand All @@ -1027,7 +1027,7 @@ static int finish_automerge(struct commit *head,
if (!head_subsumed || fast_forward == FF_NO)
commit_list_insert(head, &parents);
prepare_to_commit(remoteheads);
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents,
if (commit_tree(the_repository, merge_msg.buf, merge_msg.len, result_tree, parents,
&result_commit, NULL, sign_commit))
die(_("failed to write commit object"));
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
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
2 changes: 1 addition & 1 deletion builtin/rebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ int cmd_rebase(int argc,
options.upstream_arg = options.upstream_name;
} else {
if (!options.onto_name) {
if (commit_tree("", 0, the_hash_algo->empty_tree, NULL,
if (commit_tree(the_repository, "", 0, the_hash_algo->empty_tree, NULL,
&squash_onto, NULL, NULL) < 0)
die(_("Could not create new root commit"));
options.squash_onto = &squash_onto;
Expand Down
2 changes: 1 addition & 1 deletion builtin/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void print_new_head_line(struct commit *commit)
printf(_("HEAD is now at %s"),
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));

pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &buf);
if (buf.len > 0)
printf(" %s", buf.buf);
putchar('\n');
Expand Down
4 changes: 2 additions & 2 deletions builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
ctx.output_encoding = get_log_output_encoding();
ctx.output_encoding = get_log_output_encoding(the_repository);
ctx.color = revs->diffopt.use_color;
ctx.rev = revs;
pretty_print_commit(&ctx, commit, &buf);
pretty_print_commit(the_repository, &ctx, commit, &buf);
if (buf.len) {
if (revs->commit_format != CMIT_FMT_ONELINE)
graph_show_oneline(revs->graph);
Expand Down
4 changes: 2 additions & 2 deletions builtin/shortlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.fmt = CMIT_FMT_USERFORMAT;
ctx.abbrev = log->abbrev;
ctx.date_mode = log->date_mode;
ctx.output_encoding = get_log_output_encoding();
ctx.output_encoding = get_log_output_encoding(the_repository);

if (!log->summary) {
if (log->user_format)
pretty_print_commit(&ctx, commit, &oneline);
pretty_print_commit(the_repository, &ctx, commit, &oneline);
else
repo_format_commit_message(the_repository, commit,
"%s", &oneline, &ctx);
Expand Down
2 changes: 1 addition & 1 deletion builtin/show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void show_one_commit(struct commit *commit, int no_name)
struct commit_name *name = commit_to_name(commit);

if (commit->object.parsed) {
pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &pretty);
pretty_str = pretty.buf;
}
skip_prefix(pretty_str, "[PATCH] ", &pretty_str);
Expand Down
Loading