Merge branch 'ps/setup-wo-the-repository' into seen

Many uses of the_repository has been updated to use a more
appropriate struct repository instance in setup.c codepath.

* ps/setup-wo-the-repository:
  setup: stop using `the_repository` in `init_db()`
  setup: stop using `the_repository` in `create_reference_database()`
  setup: stop using `the_repository` in `initialize_repository_version()`
  setup: stop using `the_repository` in `check_repository_format()`
  setup: stop using `the_repository` in `upgrade_repository_format()`
  setup: stop using `the_repository` in `setup_git_directory()`
  setup: stop using `the_repository` in `setup_git_directory_gently()`
  setup: stop using `the_repository` in `setup_git_env()`
  setup: stop using `the_repository` in `set_git_work_tree()`
  setup: stop using `the_repository` in `setup_work_tree()`
  setup: stop using `the_repository` in `enter_repo()`
  setup: stop using `the_repository` in `verify_non_filename()`
  setup: stop using `the_repository` in `verify_filename()`
  setup: stop using `the_repository` in `path_inside_repo()`
  setup: stop using `the_repository` in `prefix_path()`
  setup: stop using `the_repository` in `is_inside_git_dir()`
  setup: stop using `the_repository` in `is_inside_worktree()`
  setup: replace use of `the_repository` in static functions
This commit is contained in:
Junio C Hamano
2026-04-10 16:48:32 -07:00
83 changed files with 393 additions and 377 deletions

View File

@@ -786,7 +786,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
* die ourselves; but its error message will be more specific
* than what we could write here.
*/
setup_git_directory();
setup_git_directory(the_repository);
}
parse_treeish_arg(argv, &args, remote);

View File

@@ -2813,7 +2813,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
}
if (!sb->contents_from)
setup_work_tree();
setup_work_tree(the_repository);
sb->final = fake_working_tree_commit(sb->repo,
&sb->revs->diffopt,

View File

@@ -708,7 +708,7 @@ static unsigned parse_score(const char *arg)
static char *add_prefix(const char *prefix, const char *path)
{
return prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
return prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, path);
}
static int git_blame_config(const char *var, const char *value,

View File

@@ -67,7 +67,7 @@ static void check_attr(const char *prefix, struct attr_check *check,
{
char *full_path =
prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, file);
if (collect_all) {
git_all_attrs(the_repository->index, full_path, check);
@@ -117,7 +117,7 @@ int cmd_check_attr(int argc,
int cnt, i, doubledash, filei;
if (!is_bare_repository())
setup_work_tree();
setup_work_tree(the_repository);
repo_config(the_repository, git_default_config, NULL);

View File

@@ -1,6 +1,9 @@
/*
* GIT - The information manager from hell
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "refs.h"
#include "setup.h"
@@ -41,7 +44,7 @@ static int check_ref_format_branch(const char *arg)
const char *name;
int nongit;
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
if (check_branch_ref(&sb, arg) ||
!skip_prefix(sb.buf, "refs/heads/", &name))
die("'%s' is not a valid branch name", arg);

View File

@@ -303,7 +303,7 @@ int cmd_checkout_index(int argc,
die("git checkout-index: don't mix '--all' and explicit filenames");
if (read_from_stdin)
die("git checkout-index: don't mix '--stdin' and explicit filenames");
p = prefix_path(prefix, prefix_length, arg);
p = prefix_path(repo, prefix, prefix_length, arg);
err |= checkout_file(repo->index, p, prefix);
free(p);
}
@@ -325,7 +325,7 @@ int cmd_checkout_index(int argc,
die("line is badly quoted");
strbuf_swap(&buf, &unquoted);
}
p = prefix_path(prefix, prefix_length, buf.buf);
p = prefix_path(repo, prefix, prefix_length, buf.buf);
err |= checkout_file(repo->index, p, prefix);
free(p);
}

View File

@@ -1470,7 +1470,7 @@ static int parse_branchname_arg(int argc, const char **argv,
* it would be extremely annoying.
*/
if (argc)
verify_non_filename(opts->prefix, arg);
verify_non_filename(the_repository, opts->prefix, arg);
} else if (opts->accept_pathspec) {
argcount++;
argv++;

View File

@@ -670,7 +670,7 @@ static int checkout(int submodule_progress,
}
/* We need to be in the new work tree for the checkout */
setup_work_tree();
setup_work_tree(the_repository);
repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
@@ -1170,7 +1170,7 @@ int cmd_clone(int argc,
die_errno(_("could not create work tree dir '%s'"),
work_tree);
junk_work_tree = work_tree;
set_git_work_tree(work_tree);
set_git_work_tree(the_repository, work_tree);
}
if (real_git_dir) {
@@ -1240,7 +1240,7 @@ int cmd_clone(int argc,
* repository, and reference backends may persist that information into
* their on-disk data structures.
*/
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
init_db(the_repository, git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
ref_storage_format, NULL,
do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB);
@@ -1283,7 +1283,7 @@ int cmd_clone(int argc,
*
* This is sufficient for Git commands to discover the Git directory.
*/
initialize_repository_version(GIT_HASH_UNKNOWN,
initialize_repository_version(the_repository, GIT_HASH_UNKNOWN,
the_repository->ref_storage_format, 1);
refs_create_refdir_stubs(the_repository, git_dir, NULL);
@@ -1496,9 +1496,9 @@ int cmd_clone(int argc,
* ours to the same thing.
*/
hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
repo_set_hash_algo(the_repository, hash_algo);
create_reference_database(NULL, 1);
create_reference_database(the_repository, NULL, 1);
/*
* Before fetching from the remote, download and install bundle

View File

@@ -781,7 +781,7 @@ int cmd_describe(int argc,
struct rev_info revs;
int fd;
setup_work_tree();
setup_work_tree(the_repository);
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
repo_read_index(the_repository);

View File

@@ -69,7 +69,7 @@ int cmd_diff_index(int argc,
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
usage(diff_cache_usage);
if (!(option & DIFF_INDEX_CACHED)) {
setup_work_tree();
setup_work_tree(the_repository);
if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
perror("repo_read_index_preload");
return -1;

View File

@@ -159,7 +159,7 @@ static void builtin_diff_index(struct rev_info *revs,
revs->max_age != -1)
usage(builtin_diff_usage);
if (!(option & DIFF_INDEX_CACHED)) {
setup_work_tree();
setup_work_tree(the_repository);
if (repo_read_index_preload(the_repository,
&revs->diffopt.pathspec, 0) < 0) {
die_errno("repo_read_index_preload");
@@ -281,7 +281,7 @@ static void builtin_diff_files(struct rev_info *revs, int argc, const char **arg
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
diff_merges_set_dense_combined_if_unset(revs);
setup_work_tree();
setup_work_tree(the_repository);
if (repo_read_index_preload(the_repository, &revs->diffopt.pathspec,
0) < 0) {
die_errno("repo_read_index_preload");
@@ -455,7 +455,7 @@ int cmd_diff(int argc,
break;
}
prefix = setup_git_directory_gently(&nongit);
prefix = setup_git_directory_gently(the_repository, &nongit);
if (!nongit) {
prepare_repo_settings(the_repository);
@@ -471,8 +471,8 @@ int cmd_diff(int argc,
* as a colourful "diff" replacement.
*/
if (nongit || ((argc == i + 2) &&
(!path_inside_repo(prefix, argv[i]) ||
!path_inside_repo(prefix, argv[i + 1]))))
(!path_inside_repo(the_repository, prefix, argv[i]) ||
!path_inside_repo(the_repository, prefix, argv[i + 1]))))
no_index = DIFF_NO_INDEX_IMPLICIT;
}

View File

@@ -767,7 +767,7 @@ int cmd_difftool(int argc,
die(_("difftool requires worktree or --no-index"));
if (!no_index){
setup_work_tree();
setup_work_tree(repo);
setenv(GIT_DIR_ENVIRONMENT, absolute_path(repo_get_git_dir(repo)), 1);
setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(repo_get_work_tree(repo)), 1);
} else if (dir_diff)

View File

@@ -1064,7 +1064,7 @@ int cmd_grep(int argc,
use_index = 0;
else
/* die the same way as if we did it at the beginning */
setup_git_directory();
setup_git_directory(the_repository);
}
/* Ignore --recurse-submodules if --no-index is given or implied */
if (!use_index)
@@ -1151,7 +1151,7 @@ int cmd_grep(int argc,
object = parse_object_or_die(the_repository, &oid, arg);
if (!seen_dashdash)
verify_non_filename(prefix, arg);
verify_non_filename(the_repository, prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
object_context_release(&oc);
}
@@ -1163,7 +1163,7 @@ int cmd_grep(int argc,
if (!seen_dashdash) {
int j;
for (j = i; j < argc; j++)
verify_filename(prefix, argv[j], j == i && allow_revs);
verify_filename(the_repository, prefix, argv[j], j == i && allow_revs);
}
parse_pathspec(&pathspec, 0,
@@ -1272,7 +1272,7 @@ int cmd_grep(int argc,
die(_("--[no-]exclude-standard cannot be used for tracked contents"));
} else if (!list.nr) {
if (!cached)
setup_work_tree();
setup_work_tree(the_repository);
hit = grep_cache(&opt, &pathspec, cached);
} else {

View File

@@ -100,9 +100,9 @@ int cmd_hash_object(int argc,
hash_object_usage, 0);
if (flags & INDEX_WRITE_OBJECT)
prefix = setup_git_directory();
prefix = setup_git_directory(the_repository);
else
prefix = setup_git_directory_gently(&nongit);
prefix = setup_git_directory_gently(the_repository, &nongit);
if (nongit && !the_hash_algo)
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);

View File

@@ -740,7 +740,7 @@ int cmd_help(int argc,
return 0;
}
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
repo_config(the_repository, git_help_config, NULL);
if (parsed_help_format != HELP_FORMAT_NONE)

View File

@@ -237,9 +237,9 @@ int cmd_init_db(int argc,
if (!git_work_tree_cfg)
git_work_tree_cfg = xgetcwd();
if (work_tree)
set_git_work_tree(work_tree);
set_git_work_tree(the_repository, work_tree);
else
set_git_work_tree(git_work_tree_cfg);
set_git_work_tree(the_repository, git_work_tree_cfg);
if (access(repo_get_work_tree(the_repository), X_OK))
die_errno (_("Cannot access work tree '%s'"),
repo_get_work_tree(the_repository));
@@ -248,11 +248,11 @@ int cmd_init_db(int argc,
if (real_git_dir)
die(_("--separate-git-dir incompatible with bare repository"));
if (work_tree)
set_git_work_tree(work_tree);
set_git_work_tree(the_repository, work_tree);
}
flags |= INIT_DB_EXIST_OK;
ret = init_db(git_dir, real_git_dir, template_dir, hash_algo,
ret = init_db(the_repository, git_dir, real_git_dir, template_dir, hash_algo,
ref_storage_format, initial_branch,
init_shared_repository, flags);

View File

@@ -703,8 +703,8 @@ int cmd_ls_files(int argc,
if (dir.exclude_per_dir)
exc_given = 1;
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
if (require_work_tree && !is_inside_work_tree(repo))
setup_work_tree(repo);
if (recurse_submodules &&
(show_deleted || show_others || show_unmerged ||

View File

@@ -110,7 +110,7 @@ int cmd_merge_file(int argc,
if (!repo && object_id)
/* emit the correct "not a git repo" error in this case */
setup_git_directory();
setup_git_directory(the_repository);
for (i = 0; i < 3; i++) {
char *fname;

View File

@@ -71,7 +71,7 @@ static void internal_prefix_pathspec(struct strvec *out,
trimmed = xmemdupz(pathspec[i], to_copy);
maybe_basename = (flags & DUP_BASENAME) ? basename(trimmed) : trimmed;
prefixed_path = prefix_path(prefix, prefixlen, maybe_basename);
prefixed_path = prefix_path(the_repository, prefix, prefixlen, maybe_basename);
strvec_push(out, prefixed_path);
free(prefixed_path);
@@ -394,7 +394,8 @@ dir_check:
for (j = 0; j < last - first; j++) {
const struct cache_entry *ce = the_repository->index->cache[first + j];
const char *path = ce->name;
char *prefixed_path = prefix_path(dst_with_slash, dst_with_slash_len, path + length + 1);
char *prefixed_path = prefix_path(the_repository, dst_with_slash,
dst_with_slash_len, path + length + 1);
strvec_push(&sources, path);
strvec_push(&destinations, prefixed_path);

View File

@@ -229,7 +229,7 @@ int cmd_read_tree(int argc,
opts.preserve_ignored = 0;
/* otherwise, opts.preserve_ignored is irrelevant */
if (opts.merge && !opts.index_only)
setup_work_tree();
setup_work_tree(the_repository);
if (opts.skip_sparse_checkout)
ensure_full_index(the_repository->index);

View File

@@ -2643,7 +2643,7 @@ int cmd_receive_pack(int argc,
setup_path();
if (!enter_repo(service_dir, 0))
if (!enter_repo(the_repository, service_dir, 0))
die("'%s' does not appear to be a git repository", service_dir);
repo_config(the_repository, receive_pack_config, NULL);

View File

@@ -281,11 +281,11 @@ static void parse_args(struct pathspec *pathspec,
* Ok, argv[0] looks like a commit/tree; it should not
* be a filename.
*/
verify_non_filename(prefix, argv[0]);
verify_non_filename(the_repository, prefix, argv[0]);
rev = *argv++;
} else {
/* Otherwise we treat this as a filename */
verify_filename(prefix, argv[0], 1);
verify_filename(the_repository, prefix, argv[0], 1);
}
}
@@ -468,7 +468,7 @@ int cmd_reset(int argc,
trace2_cmd_mode(reset_type_names[reset_type]);
if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository)))
setup_work_tree();
setup_work_tree(the_repository);
if (reset_type == MIXED && is_bare_repository())
die(_("%s reset is not allowed in a bare repository"),

View File

@@ -739,7 +739,7 @@ int cmd_rev_parse(int argc,
/* No options; just report on whether we're in a git repo or not. */
if (argc == 1) {
setup_git_directory();
setup_git_directory(the_repository);
repo_config(the_repository, git_default_config, NULL);
return 0;
}
@@ -749,7 +749,7 @@ int cmd_rev_parse(int argc,
if (as_is) {
if (show_file(arg, output_prefix) && as_is < 2)
verify_filename(prefix, arg, 0);
verify_filename(the_repository, prefix, arg, 0);
continue;
}
@@ -774,7 +774,7 @@ int cmd_rev_parse(int argc,
/* The rest of the options require a git repository. */
if (!did_repo_setup) {
prefix = setup_git_directory();
prefix = setup_git_directory(the_repository);
repo_config(the_repository, git_default_config, NULL);
did_repo_setup = 1;
@@ -1006,7 +1006,7 @@ int cmd_rev_parse(int argc,
}
if (!strcmp(arg, "--show-cdup")) {
const char *pfx = prefix;
if (!is_inside_work_tree()) {
if (!is_inside_work_tree(the_repository)) {
const char *work_tree =
repo_get_work_tree(the_repository);
if (work_tree)
@@ -1063,12 +1063,12 @@ int cmd_rev_parse(int argc,
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) {
printf("%s\n", is_inside_git_dir() ? "true"
printf("%s\n", is_inside_git_dir(the_repository) ? "true"
: "false");
continue;
}
if (!strcmp(arg, "--is-inside-work-tree")) {
printf("%s\n", is_inside_work_tree() ? "true"
printf("%s\n", is_inside_work_tree(the_repository) ? "true"
: "false");
continue;
}
@@ -1173,7 +1173,7 @@ int cmd_rev_parse(int argc,
as_is = 1;
if (!show_file(arg, output_prefix))
continue;
verify_filename(prefix, arg, 1);
verify_filename(the_repository, prefix, arg, 1);
}
strbuf_release(&buf);
if (verify) {

View File

@@ -296,7 +296,7 @@ int cmd_rm(int argc,
die(_("No pathspec was given. Which files should I remove?"));
if (!index_only)
setup_work_tree();
setup_work_tree(the_repository);
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;

View File

@@ -63,7 +63,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
int res;
struct repo_config_values *cfg = repo_config_values(the_repository);
setup_work_tree();
setup_work_tree(the_repository);
if (!cfg->apply_sparse_checkout)
die(_("this worktree is not sparse"));
@@ -229,7 +229,7 @@ static int update_working_directory(struct repository *r,
o.dst_index = r->index;
o.skip_sparse_checkout = 0;
setup_work_tree();
setup_work_tree(the_repository);
repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR);
@@ -468,7 +468,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix,
OPT_END(),
};
setup_work_tree();
setup_work_tree(the_repository);
repo_read_index(repo);
init_opts.cone_mode = -1;
@@ -735,7 +735,8 @@ static void sanitize_paths(struct repository *repo,
int prefix_len = strlen(prefix);
for (i = 0; i < args->nr; i++) {
char *prefixed_path = prefix_path(prefix, prefix_len, args->v[i]);
char *prefixed_path = prefix_path(the_repository, prefix,
prefix_len, args->v[i]);
strvec_replace(args, i, prefixed_path);
free(prefixed_path);
}
@@ -801,7 +802,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
int ret;
struct repo_config_values *cfg = repo_config_values(the_repository);
setup_work_tree();
setup_work_tree(the_repository);
if (!cfg->apply_sparse_checkout)
die(_("no sparse-checkout to add to"));
@@ -855,7 +856,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
struct strvec patterns = STRVEC_INIT;
int ret;
setup_work_tree();
setup_work_tree(the_repository);
repo_read_index(repo);
set_opts.cone_mode = -1;
@@ -911,7 +912,7 @@ static int sparse_checkout_reapply(int argc, const char **argv,
};
struct repo_config_values *cfg = repo_config_values(the_repository);
setup_work_tree();
setup_work_tree(the_repository);
if (!cfg->apply_sparse_checkout)
die(_("must be in a sparse-checkout to reapply sparsity patterns"));
@@ -974,7 +975,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
OPT_END(),
};
setup_work_tree();
setup_work_tree(the_repository);
if (!cfg->apply_sparse_checkout)
die(_("must be in a sparse-checkout to clean directories"));
if (!core_sparse_checkout_cone)
@@ -1052,7 +1053,7 @@ static int sparse_checkout_disable(int argc, const char **argv,
* forcibly return to a dense checkout regardless of initial state.
*/
setup_work_tree();
setup_work_tree(the_repository);
argc = parse_options(argc, argv, prefix,
builtin_sparse_checkout_disable_options,
builtin_sparse_checkout_disable_usage, 0);

View File

@@ -54,7 +54,7 @@ int cmd_stripspace(int argc,
usage_with_options(stripspace_usage, options);
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
repo_config(the_repository, git_default_config, NULL);
}

View File

@@ -1250,7 +1250,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
if (!info->cached) {
if (diff_cmd == DIFF_INDEX)
setup_work_tree();
setup_work_tree(the_repository);
if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
perror("repo_read_index_preload");
ret = -1;

View File

@@ -655,7 +655,7 @@ static int do_unresolve(int ac, const char **av,
for (i = 1; i < ac; i++) {
const char *arg = av[i];
char *p = prefix_path(prefix, prefix_length, arg);
char *p = prefix_path(the_repository, prefix, prefix_length, arg);
err |= unresolve_one(p);
free(p);
}
@@ -732,7 +732,7 @@ struct refresh_params {
static int refresh(struct refresh_params *o, unsigned int flag)
{
setup_work_tree();
setup_work_tree(the_repository);
repo_read_index(the_repository);
*o->has_errors |= refresh_index(the_repository->index, o->flags | flag, NULL,
NULL, NULL);
@@ -901,7 +901,7 @@ static enum parse_opt_result reupdate_callback(
BUG_ON_OPT_ARG(arg);
/* consume remaining arguments. */
setup_work_tree();
setup_work_tree(the_repository);
*has_errors = do_reupdate(ctx->argv + 1, prefix);
if (*has_errors)
the_repository->index->cache_changed = 0;
@@ -1157,8 +1157,8 @@ int cmd_update_index(int argc,
transaction = NULL;
}
setup_work_tree();
p = prefix_path(prefix, prefix_length, path);
setup_work_tree(the_repository);
p = prefix_path(the_repository, prefix, prefix_length, path);
update_one(p);
if (set_executable_bit)
chmod_path(set_executable_bit, p);
@@ -1199,7 +1199,7 @@ int cmd_update_index(int argc,
struct strbuf buf = STRBUF_INIT;
struct strbuf unquoted = STRBUF_INIT;
setup_work_tree();
setup_work_tree(the_repository);
while (getline_fn(&buf, stdin) != EOF) {
char *p;
if (!nul_term_line && buf.buf[0] == '"') {
@@ -1208,7 +1208,7 @@ int cmd_update_index(int argc,
die("line is badly quoted");
strbuf_swap(&buf, &unquoted);
}
p = prefix_path(prefix, prefix_length, buf.buf);
p = prefix_path(the_repository, prefix, prefix_length, buf.buf);
update_one(p);
if (set_executable_bit)
chmod_path(set_executable_bit, p);
@@ -1253,7 +1253,7 @@ int cmd_update_index(int argc,
report(_("Untracked cache disabled"));
break;
case UC_TEST:
setup_work_tree();
setup_work_tree(the_repository);
return !test_if_untracked_cache_is_supported();
case UC_ENABLE:
case UC_FORCE:

View File

@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc,
if (argc != 2)
usage(upload_archive_usage);
if (!enter_repo(argv[1], 0))
if (!enter_repo(the_repository, argv[1], 0))
die("'%s' does not appear to be a git repository", argv[1]);
init_archivers();

View File

@@ -59,7 +59,7 @@ int cmd_upload_pack(int argc,
if (strict)
enter_repo_flags |= ENTER_REPO_STRICT;
if (!enter_repo(dir, enter_repo_flags))
if (!enter_repo(the_repository, dir, enter_repo_flags))
die("'%s' does not appear to be a git repository", dir);
switch (determine_protocol_version_server()) {

View File

@@ -244,14 +244,14 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
}
enter_repo_flags = strict_paths ? ENTER_REPO_STRICT : 0;
path = enter_repo(dir, enter_repo_flags);
path = enter_repo(the_repository, dir, enter_repo_flags);
if (!path && base_path && base_path_relaxed) {
/*
* if we fail and base_path_relaxed is enabled, try without
* prefixing the base path
*/
dir = directory;
path = enter_repo(dir, enter_repo_flags);
path = enter_repo(the_repository, dir, enter_repo_flags);
}
if (!path) {

View File

@@ -147,8 +147,6 @@ void repo_config_values_init(struct repo_config_values *cfg);
* Please do not add new global config variables here.
*/
# ifdef USE_THE_REPOSITORY_VARIABLE
void setup_git_env(const char *git_dir);
/*
* Returns true iff we have a configured git repository (either via
* setup_git_directory, or in the environment via $GIT_DIR).

10
git.c
View File

@@ -84,7 +84,7 @@ static int list_cmds(const char *spec)
* Set up the repository so we can pick up any repo-level config (like
* completion.commands).
*/
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
while (*spec) {
const char *sep = strchrnul(spec, ',');
@@ -386,7 +386,7 @@ static int handle_alias(struct strvec *args, struct string_list *expanded_aliase
int nongit_ok;
/* Aliases expect GIT_PREFIX, GIT_DIR etc to be set */
setup_git_directory_gently(&nongit_ok);
setup_git_directory_gently(the_repository, &nongit_ok);
commit_pager_choice();
@@ -477,10 +477,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
run_setup = RUN_SETUP_GENTLY;
if (run_setup & RUN_SETUP) {
prefix = setup_git_directory();
prefix = setup_git_directory(the_repository);
no_repo = 0;
} else if (run_setup & RUN_SETUP_GENTLY) {
prefix = setup_git_directory_gently(&no_repo);
prefix = setup_git_directory_gently(the_repository, &no_repo);
} else {
prefix = NULL;
}
@@ -497,7 +497,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
commit_pager_choice();
if (!help && p->option & NEED_WORK_TREE)
setup_work_tree();
setup_work_tree(the_repository);
trace_argv_printf(argv, "trace: built-in: git");
trace2_cmd_name(p->cmd);

View File

@@ -809,7 +809,7 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)
not_found(&hdr, "Request not supported: '%s'", dir);
setup_path();
if (!enter_repo(dir, 0))
if (!enter_repo(the_repository, dir, 0))
not_found(&hdr, "Not a git repository: '%s'", dir);
if (!getenv("GIT_HTTP_EXPORT_ALL") &&
access("git-daemon-export-ok", F_OK) )

View File

@@ -109,7 +109,7 @@ int cmd_main(int argc, const char **argv)
struct strvec index_pack_args = STRVEC_INIT;
int ret;
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
while (arg < argc && argv[arg][0] == '-') {
const char *p;

View File

@@ -1788,7 +1788,7 @@ int cmd_main(int argc, const char **argv)
if (delete_branch && rs.nr != 1)
die("You must specify only one branch name when deleting a remote branch");
gitdir = setup_git_directory();
gitdir = setup_git_directory(the_repository);
memset(remote_dir_exists, -1, 256);

View File

@@ -1799,7 +1799,7 @@ int cmd_main(int argc, const char **argv)
int nongit_ok;
int ret;
setup_git_directory_gently(&nongit_ok);
setup_git_directory_gently(the_repository, &nongit_ok);
repo_config(the_repository, git_imap_config, &server);
argc = parse_options(argc, (const char **)argv, "", imap_send_options, imap_send_usage, 0);

View File

@@ -589,7 +589,7 @@ parse_lines(struct repository *r, struct commit *commit,
range_part = xstrndup(item->string, name_part - item->string);
name_part++;
full_name = prefix_path(prefix, prefix ? strlen(prefix) : 0,
full_name = prefix_path(r, prefix, prefix ? strlen(prefix) : 0,
name_part);
spec = alloc_filespec(full_name);

View File

@@ -378,7 +378,7 @@ void partial_clone_register(
*/
return;
} else {
if (upgrade_repository_format(1) < 0)
if (upgrade_repository_format(the_repository, 1) < 0)
die(_("unable to upgrade repository format to support partial clone"));
/* Add promisor config for the remote */

View File

@@ -1703,11 +1703,11 @@ static char *resolve_relative_path(struct repository *r, const char *rel)
if (!starts_with(rel, "./") && !starts_with(rel, "../"))
return NULL;
if (r != the_repository || !is_inside_work_tree())
if (r != the_repository || !is_inside_work_tree(the_repository))
die(_("relative path syntax can't be used outside working tree"));
/* die() inside prefix_path() if resolved path is outside worktree */
return prefix_path(startup_info->prefix,
return prefix_path(the_repository, startup_info->prefix,
startup_info->prefix ? strlen(startup_info->prefix) : 0,
rel);
}

View File

@@ -486,7 +486,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
match = xstrdup(copyfrom);
prefixlen = 0;
} else {
match = prefix_path_gently(prefix, prefixlen,
match = prefix_path_gently(the_repository, prefix, prefixlen,
&prefixlen, copyfrom);
if (!match) {
const char *hint_path;

2
refs.c
View File

@@ -3453,7 +3453,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
* repository format so that clients will use the new ref store.
* We also need to swap out the repository's main ref store.
*/
initialize_repository_version(hash_algo_by_ptr(repo->hash_algo), format, 1);
initialize_repository_version(the_repository, hash_algo_by_ptr(repo->hash_algo), format, 1);
/*
* Unset the old ref store and release it. `get_main_ref_store()` will

View File

@@ -1557,7 +1557,7 @@ int cmd_main(int argc, const char **argv)
int nongit;
int ret = 1;
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
if (argc < 2) {
error(_("remote-curl: usage: git remote-curl <remote> [<url>]"));
goto cleanup;
@@ -1605,7 +1605,7 @@ int cmd_main(int argc, const char **argv)
break;
if (starts_with(buf.buf, "fetch ")) {
if (nongit) {
setup_git_directory_gently(&nongit);
setup_git_directory_gently(the_repository, &nongit);
if (nongit)
die(_("remote-curl: fetch attempted without a local repo"));
}

View File

@@ -114,6 +114,8 @@ struct repository {
* A NULL value indicates that there is no working directory.
*/
char *worktree;
bool worktree_initialized;
bool worktree_config_is_bogus;
/*
* Path from the root of the top-level superproject down to this
@@ -279,6 +281,6 @@ void repo_update_index_if_able(struct repository *, struct lock_file *);
* Return 1 if upgrade repository format to target_version succeeded,
* 0 if no upgrade is necessary, and -1 when upgrade is not possible.
*/
int upgrade_repository_format(int target_version);
int upgrade_repository_format(struct repository *repo, int target_version);
#endif /* REPOSITORY_H */

View File

@@ -2072,7 +2072,7 @@ static int handle_dotdot_1(const char *a_name, const char *b_name,
return -1;
if (!cant_be_filename) {
verify_non_filename(revs->prefix, full_name);
verify_non_filename(the_repository, revs->prefix, full_name);
}
a_obj = parse_object(revs->repo, &a_oid);
@@ -2225,7 +2225,7 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
goto out;
}
if (!cant_be_filename)
verify_non_filename(revs->prefix, arg);
verify_non_filename(the_repository, revs->prefix, arg);
object = get_reference(revs, arg, &oid, flags ^ local_flags);
if (!object) {
ret = (revs->ignore_missing || revs->do_not_die_on_missing_objects) ? 0 : -1;
@@ -3069,7 +3069,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
* but the latter we have checked in the main loop.
*/
for (j = i; j < argc; j++)
verify_filename(revs->prefix, argv[j], j == i);
verify_filename(the_repository, revs->prefix, argv[j], j == i);
strvec_pushv(&prune_data, argv + i);
break;

View File

@@ -58,7 +58,7 @@ static void setup_enlistment_directory(int argc, const char **argv,
}
strbuf_setlen(&path, len);
setup_git_directory();
setup_git_directory(the_repository);
if (!the_repository->worktree)
die(_("Scalar enlistments require a worktree"));
@@ -514,7 +514,7 @@ static int cmd_clone(int argc, const char **argv)
goto cleanup;
}
setup_git_directory();
setup_git_directory(the_repository);
/* common-main already logs `argv` */
trace2_def_repo(the_repository);

436
setup.c

File diff suppressed because it is too large Load Diff

43
setup.h
View File

@@ -4,8 +4,8 @@
#include "refs.h"
#include "string-list.h"
int is_inside_git_dir(void);
int is_inside_work_tree(void);
int is_inside_git_dir(struct repository *repo);
int is_inside_work_tree(struct repository *repo);
int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
int get_common_dir(struct strbuf *sb, const char *gitdir);
@@ -56,7 +56,7 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code);
void die_upon_dubious_ownership(const char *gitfile, const char *worktree,
const char *gitdir);
void setup_work_tree(void);
void setup_work_tree(struct repository *repo);
/*
* discover_git_directory_reason() is similar to discover_git_directory(),
@@ -96,7 +96,7 @@ static inline int discover_git_directory(struct strbuf *commondir,
return 0;
}
void set_git_work_tree(const char *tree);
void set_git_work_tree(struct repository *repo, const char *tree);
/* Flags that can be passed to `enter_repo()`. */
enum {
@@ -134,19 +134,20 @@ enum {
* links. User relative paths are also returned as they are given,
* except DWIM suffixing.
*/
const char *enter_repo(const char *path, unsigned flags);
const char *enter_repo(struct repository *repo, const char *path, unsigned flags);
const char *setup_git_directory_gently(int *);
const char *setup_git_directory(void);
char *prefix_path(const char *prefix, int len, const char *path);
char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path);
const char *setup_git_directory_gently(struct repository *repo, int *);
const char *setup_git_directory(struct repository *repo);
char *prefix_path(struct repository *repo, const char *prefix, int len, const char *path);
char *prefix_path_gently(struct repository *repo, const char *prefix, int len, int *remaining, const char *path);
int check_filename(const char *prefix, const char *name);
void verify_filename(const char *prefix,
void verify_filename(struct repository *repo,
const char *prefix,
const char *name,
int diagnose_misspelt_rev);
void verify_non_filename(const char *prefix, const char *name);
int path_inside_repo(const char *prefix, const char *path);
void verify_non_filename(struct repository *repo, const char *prefix, const char *name);
int path_inside_repo(struct repository *repo, const char *prefix, const char *path);
void sanitize_stdfds(void);
int daemonize(void);
@@ -220,31 +221,23 @@ void clear_repository_format(struct repository_format *format);
int verify_repository_format(const struct repository_format *format,
struct strbuf *err);
/*
* Check the repository format version in the path found in repo_get_git_dir(the_repository),
* and die if it is a version we don't understand. Generally one would
* set_git_dir() before calling this, and use it only for "are we in a valid
* repo?".
*
* If successful and fmt is not NULL, fill fmt with data.
*/
void check_repository_format(struct repository_format *fmt);
const char *get_template_dir(const char *option_template);
#define INIT_DB_QUIET (1 << 0)
#define INIT_DB_EXIST_OK (1 << 1)
#define INIT_DB_SKIP_REFDB (1 << 2)
int init_db(const char *git_dir, const char *real_git_dir,
int init_db(struct repository *repo,
const char *git_dir, const char *real_git_dir,
const char *template_dir, int hash_algo,
enum ref_storage_format ref_storage_format,
const char *initial_branch, int init_shared_repository,
unsigned int flags);
void initialize_repository_version(int hash_algo,
void initialize_repository_version(struct repository *repo,
int hash_algo,
enum ref_storage_format ref_storage_format,
int reinit);
void create_reference_database(const char *initial_branch, int quiet);
void create_reference_database(struct repository *repo, const char *initial_branch, int quiet);
/*
* NOTE NOTE NOTE!!

View File

@@ -2620,7 +2620,7 @@ int get_superproject_working_tree(struct strbuf *buf)
int code;
ssize_t len;
if (!is_inside_work_tree())
if (!is_inside_work_tree(the_repository))
/*
* FIXME:
* We might have a superproject, but it is harder

View File

@@ -11,7 +11,7 @@ int cmd__advise_if_enabled(int argc, const char **argv)
if (argc != 2)
die("usage: %s <advice>", argv[0]);
setup_git_directory();
setup_git_directory(the_repository);
repo_config(the_repository, git_default_config, NULL);
/*

View File

@@ -37,7 +37,7 @@ static int bitmap_dump_pseudo_merge_objects(uint32_t n)
int cmd__bitmap(int argc, const char **argv)
{
setup_git_directory();
setup_git_directory(the_repository);
if (argc == 2 && !strcmp(argv[1], "list-commits"))
return bitmap_list_commits();

View File

@@ -52,7 +52,7 @@ static const char *const bloom_usage = "\n"
int cmd__bloom(int argc, const char **argv)
{
setup_git_directory();
setup_git_directory(the_repository);
if (argc < 2)
usage(bloom_usage);

View File

@@ -33,7 +33,7 @@ int cmd__cache_tree(int argc, const char **argv)
OPT_END()
};
setup_git_directory();
setup_git_directory(the_repository);
argc = parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);

View File

@@ -102,7 +102,7 @@ int cmd__config(int argc, const char **argv)
return 0;
}
setup_git_directory();
setup_git_directory(the_repository);
git_configset_init(&cs);

View File

@@ -66,7 +66,7 @@ int cmd__dump_cache_tree(int ac UNUSED, const char **av UNUSED)
struct cache_tree *another = cache_tree();
int ret;
setup_git_directory();
setup_git_directory(the_repository);
if (repo_read_index(the_repository) < 0)
die("unable to read index file");
istate = *the_repository->index;

View File

@@ -9,7 +9,7 @@ int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
{
struct index_state *istate = the_repository->index;
setup_git_directory();
setup_git_directory(the_repository);
if (do_read_index(istate, the_repository->index_file, 0) < 0)
die("unable to read index file");
if (!istate->fsmonitor_last_update) {

View File

@@ -17,7 +17,7 @@ int cmd__dump_split_index(int ac UNUSED, const char **av)
{
struct split_index *si;
setup_git_directory();
setup_git_directory(the_repository);
do_read_index(the_repository->index, av[1], 1);
printf("own %s\n", oid_to_hex(&the_repository->index->oid));

View File

@@ -54,7 +54,7 @@ int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)
xsetenv("GIT_CONFIG_KEY_0", "core.untrackedCache", 1);
xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
setup_git_directory();
setup_git_directory(the_repository);
if (repo_read_index(the_repository) < 0)
die("unable to read index file");
uc = the_repository->index->untracked;

View File

@@ -25,7 +25,7 @@ int cmd__find_pack(int argc, const char **argv)
struct object_id oid;
struct packed_git *p;
int count = -1, actual_count = 0;
const char *prefix = setup_git_directory();
const char *prefix = setup_git_directory(the_repository);
struct option options[] = {
OPT_INTEGER('c', "check-count", &count, "expected number of packs"),

View File

@@ -210,7 +210,7 @@ int cmd__fsmonitor_client(int argc, const char **argv)
subcmd = argv[0];
setup_git_directory();
setup_git_directory(the_repository);
if (!strcmp(subcmd, "query"))
return !!do_send_query(token);

View File

@@ -211,7 +211,7 @@ int cmd__lazy_init_name_hash(int argc, const char **argv)
const char *prefix;
uint64_t avg_single, avg_multi;
prefix = setup_git_directory();
prefix = setup_git_directory(the_repository);
argc = parse_options(argc, argv, prefix, options, usage, 0);

View File

@@ -13,7 +13,7 @@ int cmd__match_trees(int ac UNUSED, const char **av)
struct object_id hash1, hash2, shifted;
struct tree *one, *two;
setup_git_directory();
setup_git_directory(the_repository);
if (repo_get_oid(the_repository, av[1], &hash1))
die("cannot parse %s as an object name", av[1]);

View File

@@ -95,7 +95,7 @@ int cmd__pack_deltas(int argc, const char **argv)
if (argc || num_objects < 0)
usage_with_options(usage_str, options);
setup_git_directory();
setup_git_directory(the_repository);
f = hashfd(the_repository->hash_algo, 1, "<stdout>");
write_pack_header(f, num_objects);

View File

@@ -32,7 +32,7 @@ int cmd__pack_mtimes(int argc, const char **argv)
struct strbuf buf = STRBUF_INIT;
struct packed_git *p;
setup_git_directory();
setup_git_directory(the_repository);
if (argc != 2)
usage(pack_mtimes_usage);

View File

@@ -1,3 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "test-tool.h"
#include "hex.h"
#include "repository.h"
@@ -32,7 +34,7 @@ static void object_info(const char *gitdir, const char *oid_hex)
int cmd__partial_clone(int argc, const char **argv)
{
setup_git_directory();
setup_git_directory(the_repository);
if (argc < 4)
die("too few arguments");

View File

@@ -377,9 +377,9 @@ int cmd__path_utils(int argc, const char **argv)
const char *prefix = argv[2];
int prefix_len = strlen(prefix);
int nongit_ok;
setup_git_directory_gently(&nongit_ok);
setup_git_directory_gently(the_repository, &nongit_ok);
while (argc > 3) {
char *pfx = prefix_path(prefix, prefix_len, argv[3]);
char *pfx = prefix_path(the_repository, prefix, prefix_len, argv[3]);
puts(pfx);
free(pfx);

View File

@@ -89,7 +89,7 @@ int cmd__path_walk(int argc, const char **argv)
OPT_END(),
};
setup_git_directory();
setup_git_directory(the_repository);
revs.repo = the_repository;
argc = parse_options(argc, argv, NULL,

View File

@@ -39,7 +39,7 @@ int cmd__reach(int ac, const char **av)
struct strbuf buf = STRBUF_INIT;
struct repository *r = the_repository;
setup_git_directory();
setup_git_directory(the_repository);
if (ac < 2)
exit(1);

View File

@@ -19,7 +19,7 @@ int cmd__read_cache(int argc, const char **argv)
if (argc == 2)
cnt = strtol(argv[1], NULL, 0);
setup_git_directory();
setup_git_directory(the_repository);
repo_config(the_repository, git_default_config, NULL);
for (i = 0; i < cnt; i++) {

View File

@@ -76,7 +76,7 @@ int cmd__read_graph(int argc, const char **argv)
struct odb_source *source;
int ret = 0;
setup_git_directory();
setup_git_directory(the_repository);
source = the_repository->objects->sources;
prepare_repo_settings(the_repository);

View File

@@ -14,7 +14,7 @@
static struct multi_pack_index *setup_midx(const char *object_dir)
{
struct odb_source *source;
setup_git_directory();
setup_git_directory(the_repository);
source = odb_find_source(the_repository->objects, object_dir);
if (!source)
source = odb_add_to_alternates_memory(the_repository->objects,

View File

@@ -340,7 +340,7 @@ int cmd__ref_store(int argc UNUSED, const char **argv)
const char *func;
struct command *cmd;
setup_git_directory();
setup_git_directory(the_repository);
argv = get_store(argv + 1, &refs);

View File

@@ -56,7 +56,7 @@ int cmd__revision_walking(int argc, const char **argv)
if (argc < 2)
return 1;
setup_git_directory();
setup_git_directory(the_repository);
if (!strcmp(argv[1], "run-twice")) {
printf("1st\n");

View File

@@ -12,7 +12,7 @@ int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
{
struct lock_file index_lock = LOCK_INIT;
setup_git_directory();
setup_git_directory(the_repository);
repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
if (repo_read_index(the_repository) < 0)
die("unable to read index file");

View File

@@ -23,7 +23,7 @@ int cmd__serve_v2(int argc, const char **argv)
N_("exit immediately after advertising capabilities")),
OPT_END()
};
const char *prefix = setup_git_directory();
const char *prefix = setup_git_directory(the_repository);
/* ignore all unknown cmdline switches for now */
argc = parse_options(argc, argv, prefix, options, serve_usage,

View File

@@ -34,7 +34,7 @@ int cmd__submodule_config(int argc, const char **argv)
if (my_argc % 2 != 0)
die_usage(argc, argv, "Wrong number of arguments.");
setup_git_directory();
setup_git_directory(the_repository);
while (*arg) {
struct object_id commit_oid;

View File

@@ -19,7 +19,7 @@ int cmd__submodule_nested_repo_config(int argc, const char **argv)
if (argc < 3)
die_usage(argv, "Wrong number of arguments.");
setup_git_directory();
setup_git_directory(the_repository);
if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid(the_hash_algo))) {
die_usage(argv, "Submodule not found.");

View File

@@ -99,7 +99,7 @@ static int cmd__submodule_is_active(int argc, const char **argv)
if (argc != 1)
usage_with_options(submodule_is_active_usage, options);
setup_git_directory();
setup_git_directory(the_repository);
return !is_submodule_active(the_repository, argv[0]);
}
@@ -142,7 +142,7 @@ static int cmd__submodule_config_list(int argc, const char **argv)
argc = parse_options(argc, argv, "test-tools", options, usage,
PARSE_OPT_KEEP_ARGV0);
setup_git_directory();
setup_git_directory(the_repository);
if (argc == 2)
return print_config_from_gitmodules(the_repository, argv[1]);
@@ -161,7 +161,7 @@ static int cmd__submodule_config_set(int argc, const char **argv)
argc = parse_options(argc, argv, "test-tools", options, usage,
PARSE_OPT_KEEP_ARGV0);
setup_git_directory();
setup_git_directory(the_repository);
/* Equivalent to ACTION_SET in builtin/config.c */
if (argc == 3) {
@@ -183,7 +183,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
NULL
};
setup_git_directory();
setup_git_directory(the_repository);
if (argc == 2) {
if (!is_writing_gitmodules_ok())
@@ -202,7 +202,7 @@ static int cmd__submodule_config_writeable(int argc, const char **argv UNUSED)
"test-tool submodule config-writeable",
NULL
};
setup_git_directory();
setup_git_directory(the_repository);
if (argc == 1)
return is_writing_gitmodules_ok() ? 0 : -1;

View File

@@ -1,3 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "test-tool.h"
#include "run-command.h"
#include "setup.h"
@@ -7,11 +9,11 @@ int cmd__subprocess(int argc, const char **argv)
struct child_process cp = CHILD_PROCESS_INIT;
int nogit = 0;
setup_git_directory_gently(&nogit);
setup_git_directory_gently(the_repository, &nogit);
if (nogit)
die("No git repo found");
if (argc > 1 && !strcmp(argv[1], "--setup-work-tree")) {
setup_work_tree();
setup_work_tree(the_repository);
argv++;
}
cp.git_cmd = 1;

View File

@@ -40,7 +40,7 @@ int cmd__userdiff(int argc, const char **argv)
return error("unknown argument %s", argv[1]);
if (want & USERDIFF_DRIVER_TYPE_CUSTOM) {
setup_git_directory();
setup_git_directory(the_repository);
repo_config(the_repository, cmd__userdiff_config, NULL);
}

View File

@@ -12,7 +12,7 @@ int cmd__write_cache(int argc, const char **argv)
int i, cnt = 1;
if (argc == 2)
cnt = strtol(argv[1], NULL, 0);
setup_git_directory();
setup_git_directory(the_repository);
repo_read_index(the_repository);
for (i = 0; i < cnt; i++) {
repo_hold_locked_index(the_repository, &index_lock,

View File

@@ -1104,7 +1104,7 @@ void write_worktree_linking_files(const char *dotgit, const char *gitdir,
strbuf_realpath(&repo, repo.buf, 1);
if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
if (upgrade_repository_format(1) < 0)
if (upgrade_repository_format(the_repository, 1) < 0)
die(_("unable to upgrade repository format to support relative worktrees"));
if (repo_config_set_gently(the_repository, "extensions.relativeWorktrees", "true"))
die(_("unable to set extensions.relativeWorktrees setting"));

View File

@@ -1206,7 +1206,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
status_printf_ln(s, c,
"--------------------------------------------------");
status_printf_ln(s, c, _("Changes not staged for commit:"));
setup_work_tree();
setup_work_tree(the_repository);
rev.diffopt.a_prefix = "i/";
rev.diffopt.b_prefix = "w/";
run_diff_files(&rev, 0);