Skip to content

Commit

Permalink
Merge branch 'ps/the-repository' into next
Browse files Browse the repository at this point in the history
More code paths have a repository passed through the callchain,
instead of assuming the primary the_repository object.

* ps/the-repository:
  match-trees: stop using `the_repository`
  graph: stop using `the_repository`
  add-interactive: stop using `the_repository`
  tmp-objdir: stop using `the_repository`
  resolve-undo: stop using `the_repository`
  credential: stop using `the_repository`
  mailinfo: stop using `the_repository`
  diagnose: stop using `the_repository`
  server-info: stop using `the_repository`
  send-pack: stop using `the_repository`
  serve: stop using `the_repository`
  trace: stop using `the_repository`
  pager: stop using `the_repository`
  progress: stop using `the_repository`
  • Loading branch information
gitster committed Jan 9, 2025
2 parents d08b30f + d4cd757 commit 1de40ed
Show file tree
Hide file tree
Showing 74 changed files with 407 additions and 299 deletions.
19 changes: 9 additions & 10 deletions add-interactive.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS

#include "git-compat-util.h"
Expand Down Expand Up @@ -72,14 +71,14 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);

FREE_AND_NULL(s->interactive_diff_filter);
git_config_get_string("interactive.difffilter",
&s->interactive_diff_filter);
repo_config_get_string(r, "interactive.difffilter",
&s->interactive_diff_filter);

FREE_AND_NULL(s->interactive_diff_algorithm);
git_config_get_string("diff.algorithm",
&s->interactive_diff_algorithm);
repo_config_get_string(r, "diff.algorithm",
&s->interactive_diff_algorithm);

git_config_get_bool("interactive.singlekey", &s->use_single_key);
repo_config_get_bool(r, "interactive.singlekey", &s->use_single_key);
if (s->use_single_key)
setbuf(stdin, NULL);
}
Expand Down Expand Up @@ -535,7 +534,7 @@ static int get_modified_files(struct repository *r,
size_t *binary_count)
{
struct object_id head_oid;
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(r),
"HEAD", RESOLVE_REF_READING,
&head_oid, NULL);
struct collection_status s = { 0 };
Expand All @@ -560,7 +559,7 @@ static int get_modified_files(struct repository *r,
s.skip_unseen = filter && i;

opt.def = is_initial ?
empty_tree_oid_hex(the_repository->hash_algo) : oid_to_hex(&head_oid);
empty_tree_oid_hex(r->hash_algo) : oid_to_hex(&head_oid);

repo_init_revisions(r, &rev, NULL);
setup_revisions(0, NULL, &rev, &opt);
Expand Down Expand Up @@ -765,7 +764,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,
size_t count, i, j;

struct object_id oid;
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),
"HEAD", RESOLVE_REF_READING,
&oid,
NULL);
Expand Down Expand Up @@ -996,7 +995,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
ssize_t count, i;

struct object_id oid;
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),
"HEAD", RESOLVE_REF_READING,
&oid,
NULL);
Expand Down
2 changes: 1 addition & 1 deletion add-patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ static int patch_update_file(struct add_p_state *s,
if (file_diff->hunk_nr) {
if (rendered_hunk_index != hunk_index) {
if (use_pager) {
setup_pager();
setup_pager(the_repository);
sigchain_push(SIGPIPE, SIG_IGN);
}
render_hunk(s, hunk, 0, colored, &s->buf);
Expand Down
6 changes: 3 additions & 3 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ static int parse_mail(struct am_state *state, const char *mail)
int ret = 0;
struct mailinfo mi;

setup_mailinfo(&mi);
setup_mailinfo(the_repository, &mi);

if (state->utf8)
mi.metainfo_charset = get_commit_output_encoding();
Expand Down Expand Up @@ -1786,7 +1786,7 @@ static int do_interactive(struct am_state *state)
}
strbuf_release(&msg);
} else if (*reply == 'v' || *reply == 'V') {
const char *pager = git_pager(1);
const char *pager = git_pager(the_repository, 1);
struct child_process cp = CHILD_PROCESS_INIT;

if (!pager)
Expand Down Expand Up @@ -2246,7 +2246,7 @@ static int show_patch(struct am_state *state, enum resume_type resume_mode)
if (len < 0)
die_errno(_("failed to read '%s'"), patch_path);

setup_pager();
setup_pager(the_repository);
write_in_full(1, sb.buf, sb.len);
strbuf_release(&sb);
return 0;
Expand Down
6 changes: 4 additions & 2 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,16 @@ int cmd_blame(int argc,
sb.found_guilty_entry = &found_guilty_entry;
sb.found_guilty_entry_data = &pi;
if (show_progress)
pi.progress = start_delayed_progress(_("Blaming lines"), num_lines);
pi.progress = start_delayed_progress(the_repository,
_("Blaming lines"),
num_lines);

assign_blame(&sb, opt);

stop_progress(&pi.progress);

if (!incremental)
setup_pager();
setup_pager(the_repository);
else
goto cleanup;

Expand Down
2 changes: 1 addition & 1 deletion builtin/bugreport.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int cmd_bugreport(int argc,
strbuf_addftime(&zip_path, option_suffix, localtime_r(&now, &tm), 0, 0);
strbuf_addstr(&zip_path, ".zip");

if (create_diagnostics_archive(&zip_path, diagnose))
if (create_diagnostics_archive(the_repository, &zip_path, diagnose))
die_errno(_("unable to create diagnostics archive %s"), zip_path.buf);

strbuf_release(&zip_path);
Expand Down
1 change: 1 addition & 0 deletions builtin/commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
oidset_init(&commits, 0);
if (opts.progress)
progress = start_delayed_progress(
the_repository,
_("Collecting commits from input"), 0);

while (strbuf_getline(&buf, stdin) != EOF) {
Expand Down
6 changes: 3 additions & 3 deletions builtin/credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ int cmd_credential(int argc,
die("unable to read credential from stdin");

if (!strcmp(op, "fill")) {
credential_fill(&c, 0);
credential_fill(the_repository, &c, 0);
credential_next_state(&c);
credential_write(&c, stdout, CREDENTIAL_OP_RESPONSE);
} else if (!strcmp(op, "approve")) {
credential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);
credential_approve(&c);
credential_approve(the_repository, &c);
} else if (!strcmp(op, "reject")) {
credential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);
credential_reject(&c);
credential_reject(the_repository, &c);
} else {
usage(usage_msg);
}
Expand Down
4 changes: 3 additions & 1 deletion builtin/diagnose.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
Expand Down Expand Up @@ -58,7 +60,7 @@ int cmd_diagnose(int argc,
}

/* Prepare diagnostics */
if (create_diagnostics_archive(&zip_path, mode))
if (create_diagnostics_archive(the_repository, &zip_path, mode))
die_errno(_("unable to create diagnostics archive %s"),
zip_path.buf);

Expand Down
12 changes: 8 additions & 4 deletions builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static int traverse_reachable(void)
unsigned int nr = 0;
int result = 0;
if (show_progress)
progress = start_delayed_progress(_("Checking connectivity"), 0);
progress = start_delayed_progress(the_repository,
_("Checking connectivity"), 0);
while (pending.nr) {
result |= traverse_one_object(object_array_pop(&pending));
display_progress(progress, ++nr);
Expand Down Expand Up @@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)
fprintf_ln(stderr, _("Checking object directory"));

if (show_progress)
progress = start_progress(_("Checking object directories"), 256);
progress = start_progress(the_repository,
_("Checking object directories"), 256);

for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
&cb_data);
Expand Down Expand Up @@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)
if (show_progress) {
for (struct packed_git *p = get_all_packs(r); p; p = p->next)
pack_count++;
progress = start_delayed_progress("Verifying reverse pack-indexes", pack_count);
progress = start_delayed_progress(the_repository,
"Verifying reverse pack-indexes", pack_count);
pack_count = 0;
}

Expand Down Expand Up @@ -989,7 +992,8 @@ int cmd_fsck(int argc,
total += p->num_objects;
}

progress = start_progress(_("Checking objects"), total);
progress = start_progress(the_repository,
_("Checking objects"), total);
}
for (p = get_all_packs(the_repository); p;
p = p->next) {
Expand Down
4 changes: 2 additions & 2 deletions builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ int cmd_grep(int argc,
}

if (show_in_pager == default_pager)
show_in_pager = git_pager(1);
show_in_pager = git_pager(the_repository, 1);
if (show_in_pager) {
opt.color = 0;
opt.name_only = 1;
Expand Down Expand Up @@ -1246,7 +1246,7 @@ int cmd_grep(int argc,
}

if (!show_in_pager && !opt.status_only)
setup_pager();
setup_pager(the_repository);

die_for_incompatible_opt3(!use_index, "--no-index",
untracked, "--untracked",
Expand Down
4 changes: 2 additions & 2 deletions builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ int cmd_help(int argc,
case HELP_ACTION_ALL:
opt_mode_usage(argc, "--all", help_format);
if (verbose) {
setup_pager();
setup_pager(the_repository);
list_all_cmds_help(show_external_commands,
show_aliases);
return 0;
Expand Down Expand Up @@ -692,7 +692,7 @@ int cmd_help(int argc,
return 0;
case HELP_ACTION_CONFIG:
opt_mode_usage(argc, "--config", help_format);
setup_pager();
setup_pager(the_repository);
list_config_help(SHOW_CONFIG_HUMAN);
printf("\n%s\n", _("'git help config' for more information"));
return 0;
Expand Down
7 changes: 5 additions & 2 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ static unsigned check_objects(void)
max = get_max_object_index();

if (verbose)
progress = start_delayed_progress(_("Checking objects"), max);
progress = start_delayed_progress(the_repository,
_("Checking objects"), max);

for (i = 0; i < max; i++) {
foreign_nr += check_object(get_indexed_object(i));
Expand Down Expand Up @@ -1249,6 +1250,7 @@ static void parse_pack_objects(unsigned char *hash)

if (verbose)
progress = start_progress(
the_repository,
progress_title ? progress_title :
from_stdin ? _("Receiving objects") : _("Indexing objects"),
nr_objects);
Expand Down Expand Up @@ -1329,7 +1331,8 @@ static void resolve_deltas(struct pack_idx_option *opts)
QSORT(ref_deltas, nr_ref_deltas, compare_ref_delta_entry);

if (verbose || show_resolving_progress)
progress = start_progress(_("Resolving deltas"),
progress = start_progress(the_repository,
_("Resolving deltas"),
nr_ref_deltas + nr_ofs_deltas);

nr_dispatched = 0;
Expand Down
7 changes: 4 additions & 3 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
if (rev->line_level_traverse)
line_log_init(rev, line_cb.prefix, &line_cb.args);

setup_pager();
setup_pager(the_repository);
}

static void cmd_log_init(int argc, const char **argv, const char *prefix,
Expand Down Expand Up @@ -2295,7 +2295,7 @@ int cmd_format_patch(int argc,
rev.commit_format = CMIT_FMT_MBOXRD;

if (use_stdout) {
setup_pager();
setup_pager(the_repository);
} else if (!rev.diffopt.close_file) {
int saved;

Expand Down Expand Up @@ -2498,7 +2498,8 @@ int cmd_format_patch(int argc,
rev.add_signoff = cfg.do_signoff;

if (show_progress)
progress = start_delayed_progress(_("Generating patches"), total);
progress = start_delayed_progress(the_repository,
_("Generating patches"), total);
for (i = 0; i < nr; i++) {
size_t idx = nr - i - 1;
int shown;
Expand Down
2 changes: 1 addition & 1 deletion builtin/mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int cmd_mailinfo(int argc,
OPT_END()
};

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

argc = parse_options(argc, argv, prefix, options, mailinfo_usage, 0);
Expand Down
21 changes: 14 additions & 7 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ static void write_pack_file(void)
struct object_entry **write_order;

if (progress > pack_to_stdout)
progress_state = start_progress(_("Writing objects"), nr_result);
progress_state = start_progress(the_repository,
_("Writing objects"), nr_result);
ALLOC_ARRAY(written_list, to_pack.nr_objects);
write_order = compute_write_order();

Expand Down Expand Up @@ -2400,7 +2401,8 @@ static void get_object_details(void)
struct object_entry **sorted_by_offset;

if (progress)
progress_state = start_progress(_("Counting objects"),
progress_state = start_progress(the_repository,
_("Counting objects"),
to_pack.nr_objects);

CALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects);
Expand Down Expand Up @@ -3220,7 +3222,8 @@ static void prepare_pack(int window, int depth)
unsigned nr_done = 0;

if (progress)
progress_state = start_progress(_("Compressing objects"),
progress_state = start_progress(the_repository,
_("Compressing objects"),
nr_deltas);
QSORT(delta_list, n, type_size_sort);
ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
Expand Down Expand Up @@ -3648,7 +3651,8 @@ static void add_objects_in_unpacked_packs(void);
static void enumerate_cruft_objects(void)
{
if (progress)
progress_state = start_progress(_("Enumerating cruft objects"), 0);
progress_state = start_progress(the_repository,
_("Enumerating cruft objects"), 0);

add_objects_in_unpacked_packs();
add_unreachable_loose_objects();
Expand All @@ -3674,7 +3678,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
revs.ignore_missing_links = 1;

if (progress)
progress_state = start_progress(_("Enumerating cruft objects"), 0);
progress_state = start_progress(the_repository,
_("Enumerating cruft objects"), 0);
ret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration,
set_cruft_mtime, 1);
stop_progress(&progress_state);
Expand All @@ -3693,7 +3698,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
if (progress)
progress_state = start_progress(_("Traversing cruft objects"), 0);
progress_state = start_progress(the_repository,
_("Traversing cruft objects"), 0);
nr_seen = 0;
traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);

Expand Down Expand Up @@ -4625,7 +4631,8 @@ int cmd_pack_objects(int argc,
prepare_packing_data(the_repository, &to_pack);

if (progress && !cruft)
progress_state = start_progress(_("Enumerating objects"), 0);
progress_state = start_progress(the_repository,
_("Enumerating objects"), 0);
if (stdin_packs) {
/* avoids adding objects in excluded packs */
ignore_packed_keep_in_core = 1;
Expand Down
3 changes: 2 additions & 1 deletion builtin/prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)
return;

if (show_progress)
progress = start_delayed_progress(_("Checking connectivity"), 0);
progress = start_delayed_progress(the_repository,
_("Checking connectivity"), 0);
mark_reachable_objects(revs, 1, expire, progress);
stop_progress(&progress);
initialized = 1;
Expand Down
Loading

0 comments on commit 1de40ed

Please sign in to comment.