aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/am.c13
-rw-r--r--builtin/blame.c2
-rw-r--r--builtin/checkout.c5
-rw-r--r--builtin/commit-graph.c5
-rw-r--r--builtin/commit.c13
-rw-r--r--builtin/config.c4
-rw-r--r--builtin/count-objects.c3
-rw-r--r--builtin/difftool.c9
-rw-r--r--builtin/fsmonitor--daemon.c7
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/init-db.c4
-rw-r--r--builtin/merge.c18
-rw-r--r--builtin/multi-pack-index.c4
-rw-r--r--builtin/notes.c22
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/prune.c8
-rw-r--r--builtin/repack.c7
-rw-r--r--builtin/replace.c3
-rw-r--r--builtin/reset.c5
-rw-r--r--builtin/rev-parse.c11
-rw-r--r--builtin/stash.c17
-rw-r--r--builtin/submodule--helper.c2
-rw-r--r--builtin/update-index.c4
-rw-r--r--builtin/worktree.c4
-rw-r--r--builtin/write-tree.c4
25 files changed, 101 insertions, 77 deletions
diff --git a/builtin/am.c b/builtin/am.c
index d8875ad402..5498ddeb6a 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1544,7 +1544,8 @@ static int run_apply(const struct am_state *state, const char *index_file)
if (index_file) {
/* Reload index as apply_all_patches() will have modified it. */
discard_index(the_repository->index);
- read_index_from(the_repository->index, index_file, get_git_dir());
+ read_index_from(the_repository->index, index_file,
+ repo_get_git_dir(the_repository));
}
return 0;
@@ -1587,7 +1588,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
return error("could not build fake ancestor");
discard_index(the_repository->index);
- read_index_from(the_repository->index, index_path, get_git_dir());
+ read_index_from(the_repository->index, index_path, repo_get_git_dir(the_repository));
if (write_index_as_tree(&bases[0], the_repository->index, index_path, 0, NULL))
return error(_("Repository lacks necessary blobs to fall back on 3-way merge."));
@@ -1667,7 +1668,9 @@ static void do_commit(const struct am_state *state)
if (!state->no_verify && run_hooks(the_repository, "pre-applypatch"))
exit(1);
- if (write_index_as_tree(&tree, the_repository->index, get_index_file(), 0, NULL))
+ if (write_index_as_tree(&tree, the_repository->index,
+ repo_get_index_file(the_repository),
+ 0, NULL))
die(_("git write-tree failed to write a tree"));
if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
@@ -2077,7 +2080,9 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
if (fast_forward_to(head_tree, head_tree, 1))
return -1;
- if (write_index_as_tree(&index, the_repository->index, get_index_file(), 0, NULL))
+ if (write_index_as_tree(&index, the_repository->index,
+ repo_get_index_file(the_repository),
+ 0, NULL))
return -1;
index_tree = parse_tree_indirect(&index);
diff --git a/builtin/blame.c b/builtin/blame.c
index 35e975fb13..1ffdda5090 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1081,7 +1081,7 @@ parse_done:
path = add_prefix(prefix, argv[1]);
argv[1] = argv[2];
} else { /* (2a) */
- if (argc == 2 && is_a_rev(argv[1]) && !get_git_work_tree())
+ if (argc == 2 && is_a_rev(argv[1]) && !repo_get_work_tree(the_repository))
die("missing <path> to blame");
path = add_prefix(prefix, argv[argc - 1]);
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4cfe6fab50..7e18b87c7a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -23,6 +23,7 @@
#include "read-cache.h"
#include "refs.h"
#include "remote.h"
+#include "repo-settings.h"
#include "resolve-undo.h"
#include "revision.h"
#include "setup.h"
@@ -950,11 +951,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
const char *old_desc, *reflog_msg;
if (opts->new_branch) {
if (opts->new_orphan_branch) {
+ enum log_refs_config log_all_ref_updates =
+ repo_settings_get_log_all_ref_updates(the_repository);
char *refname;
refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
if (opts->new_branch_log &&
- !should_autocreate_reflog(refname)) {
+ !should_autocreate_reflog(log_all_ref_updates, refname)) {
int ret;
struct strbuf err = STRBUF_INIT;
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 7102ee90a0..7411e6244f 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -1,7 +1,6 @@
#include "builtin.h"
#include "commit.h"
#include "config.h"
-#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "parse-options.h"
@@ -95,7 +94,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix)
usage_with_options(builtin_commit_graph_verify_usage, options);
if (!opts.obj_dir)
- opts.obj_dir = get_object_directory();
+ opts.obj_dir = repo_get_object_directory(the_repository);
if (opts.shallow)
flags |= COMMIT_GRAPH_VERIFY_SHALLOW;
if (opts.progress)
@@ -275,7 +274,7 @@ static int graph_write(int argc, const char **argv, const char *prefix)
if (opts.reachable + opts.stdin_packs + opts.stdin_commits > 1)
die(_("use at most one of --reachable, --stdin-commits, or --stdin-packs"));
if (!opts.obj_dir)
- opts.obj_dir = get_object_directory();
+ opts.obj_dir = repo_get_object_directory(the_repository);
if (opts.append)
flags |= COMMIT_GRAPH_WRITE_APPEND;
if (opts.split)
diff --git a/builtin/commit.c b/builtin/commit.c
index b2033c4887..b09320f907 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -26,6 +26,7 @@
#include "path.h"
#include "preload-index.h"
#include "read-cache.h"
+#include "repository.h"
#include "string-list.h"
#include "rerere.h"
#include "unpack-trees.h"
@@ -407,7 +408,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
discard_index(the_repository->index);
read_index_from(the_repository->index, get_lock_file_path(&index_lock),
- get_git_dir());
+ repo_get_git_dir(the_repository));
if (cache_tree_update(the_repository->index, WRITE_TREE_SILENT) == 0) {
if (reopen_lock_file(&index_lock) < 0)
die(_("unable to write index file"));
@@ -472,7 +473,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
die(_("unable to write new index file"));
commit_style = COMMIT_AS_IS;
- ret = get_index_file();
+ ret = repo_get_index_file(the_repository);
goto out;
}
@@ -534,7 +535,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
discard_index(the_repository->index);
ret = get_lock_file_path(&false_lock);
- read_index_from(the_repository->index, ret, get_git_dir());
+ read_index_from(the_repository->index, ret, repo_get_git_dir(the_repository));
out:
string_list_clear(&partial, 0);
clear_pathspec(&pathspec);
@@ -1072,7 +1073,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
*/
discard_index(the_repository->index);
}
- read_index_from(the_repository->index, index_file, get_git_dir());
+ read_index_from(the_repository->index, index_file, repo_get_git_dir(the_repository));
if (cache_tree_update(the_repository->index, 0)) {
error(_("Error building trees"));
@@ -1873,8 +1874,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
repo_rerere(the_repository, 0);
run_auto_maintenance(quiet);
- run_commit_hook(use_editor, get_index_file(), NULL, "post-commit",
- NULL);
+ run_commit_hook(use_editor, repo_get_index_file(the_repository),
+ NULL, "post-commit", NULL);
if (amend && !no_post_rewrite) {
commit_post_rewrite(the_repository, current_head, &oid);
}
diff --git a/builtin/config.c b/builtin/config.c
index 95c8a00915..596a01c788 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -807,8 +807,8 @@ static void location_options_init(struct config_location_options *opts,
else
opts->options.respect_includes = opts->respect_includes_opt;
if (startup_info->have_repository) {
- opts->options.commondir = get_git_common_dir();
- opts->options.git_dir = get_git_dir();
+ opts->options.commondir = repo_get_common_dir(the_repository);
+ opts->options.git_dir = repo_get_git_dir(the_repository);
}
}
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index ec6098a149..42275f62d5 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -7,7 +7,6 @@
#include "builtin.h"
#include "config.h"
#include "dir.h"
-#include "environment.h"
#include "gettext.h"
#include "path.h"
#include "repository.h"
@@ -116,7 +115,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
report_linked_checkout_garbage(the_repository);
}
- for_each_loose_file_in_objdir(get_object_directory(),
+ for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
count_loose, count_cruft, NULL, NULL);
if (verbose) {
diff --git a/builtin/difftool.c b/builtin/difftool.c
index dcc68e190c..7f2cbd797a 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -22,6 +22,7 @@
#include "hex.h"
#include "parse-options.h"
#include "read-cache-ll.h"
+#include "repository.h"
#include "sparse-index.h"
#include "strvec.h"
#include "strbuf.h"
@@ -214,7 +215,7 @@ static void changed_files(struct hashmap *result, const char *index_path,
struct child_process update_index = CHILD_PROCESS_INIT;
struct child_process diff_files = CHILD_PROCESS_INIT;
struct strbuf buf = STRBUF_INIT;
- const char *git_dir = absolute_path(get_git_dir());
+ const char *git_dir = absolute_path(repo_get_git_dir(the_repository));
FILE *fp;
strvec_pushl(&update_index.args,
@@ -377,7 +378,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
struct hashmap wt_modified, tmp_modified;
int indices_loaded = 0;
- workdir = get_git_work_tree();
+ workdir = repo_get_work_tree(the_repository);
/* Setup temp directories */
tmp = getenv("TMPDIR");
@@ -737,8 +738,8 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
if (!no_index){
setup_work_tree();
- setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1);
- setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1);
+ setenv(GIT_DIR_ENVIRONMENT, absolute_path(repo_get_git_dir(the_repository)), 1);
+ setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(repo_get_work_tree(the_repository)), 1);
} else if (dir_diff)
die(_("options '%s' and '%s' cannot be used together"), "--dir-diff", "--no-index");
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index 1593713f4c..25451d999e 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -2,7 +2,6 @@
#include "abspath.h"
#include "config.h"
#include "dir.h"
-#include "environment.h"
#include "gettext.h"
#include "parse-options.h"
#include "fsmonitor-ll.h"
@@ -1291,7 +1290,8 @@ static int fsmonitor_run_daemon(void)
/* Prepare to (recursively) watch the <worktree-root> directory. */
strbuf_init(&state.path_worktree_watch, 0);
- strbuf_addstr(&state.path_worktree_watch, absolute_path(get_git_work_tree()));
+ strbuf_addstr(&state.path_worktree_watch,
+ absolute_path(repo_get_work_tree(the_repository)));
state.nr_paths_watching = 1;
strbuf_init(&state.alias.alias, 0);
@@ -1311,7 +1311,8 @@ static int fsmonitor_run_daemon(void)
strbuf_addstr(&state.path_gitdir_watch, "/.git");
if (!is_directory(state.path_gitdir_watch.buf)) {
strbuf_reset(&state.path_gitdir_watch);
- strbuf_addstr(&state.path_gitdir_watch, absolute_path(get_git_dir()));
+ strbuf_addstr(&state.path_gitdir_watch,
+ absolute_path(repo_get_git_dir(the_repository)));
state.nr_paths_watching = 2;
}
diff --git a/builtin/gc.c b/builtin/gc.c
index 7dac971405..ed18463f1b 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -2132,7 +2132,7 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
get_schedule_cmd(&cmd, NULL);
strbuf_addf(&tfilename, "%s/schedule_%s_XXXXXX",
- get_git_common_dir(), frequency);
+ repo_get_common_dir(the_repository), frequency);
tfile = xmks_tempfile(tfilename.buf);
strbuf_release(&tfilename);
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 582dcf20f8..fb04962dce 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -231,9 +231,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
set_git_work_tree(work_tree);
else
set_git_work_tree(git_work_tree_cfg);
- if (access(get_git_work_tree(), X_OK))
+ if (access(repo_get_work_tree(the_repository), X_OK))
die_errno (_("Cannot access work tree '%s'"),
- get_git_work_tree());
+ repo_get_work_tree(the_repository));
}
else {
if (real_git_dir)
diff --git a/builtin/merge.c b/builtin/merge.c
index 662a49a0e8..7f5475f738 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -17,6 +17,7 @@
#include "object-name.h"
#include "parse-options.h"
#include "lockfile.h"
+#include "repository.h"
#include "run-command.h"
#include "hook.h"
#include "diff.h"
@@ -695,7 +696,9 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,
static void write_tree_trivial(struct object_id *oid)
{
- if (write_index_as_tree(oid, the_repository->index, get_index_file(), 0, NULL))
+ if (write_index_as_tree(oid, the_repository->index,
+ repo_get_index_file(the_repository),
+ 0, NULL))
die(_("git write-tree failed to write a tree"));
}
@@ -757,7 +760,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
}
if (write_locked_index(the_repository->index, &lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
- die(_("unable to write %s"), get_index_file());
+ die(_("unable to write %s"), repo_get_index_file(the_repository));
return clean ? 0 : 1;
} else {
return try_merge_command(the_repository,
@@ -839,7 +842,7 @@ static void write_merge_heads(struct commit_list *);
static void prepare_to_commit(struct commit_list *remoteheads)
{
struct strbuf msg = STRBUF_INIT;
- const char *index_file = get_index_file();
+ const char *index_file = repo_get_index_file(the_repository);
if (!no_verify) {
int invoked_hook;
@@ -855,7 +858,8 @@ static void prepare_to_commit(struct commit_list *remoteheads)
if (invoked_hook)
discard_index(the_repository->index);
}
- read_index_from(the_repository->index, index_file, get_git_dir());
+ read_index_from(the_repository->index, index_file,
+ repo_get_git_dir(the_repository));
strbuf_addbuf(&msg, &merge_msg);
if (squash)
BUG("the control must not reach here under --squash");
@@ -878,8 +882,8 @@ static void prepare_to_commit(struct commit_list *remoteheads)
append_signoff(&msg, ignored_log_message_bytes(msg.buf, msg.len), 0);
write_merge_heads(remoteheads);
write_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);
- if (run_commit_hook(0 < option_edit, get_index_file(), NULL,
- "prepare-commit-msg",
+ if (run_commit_hook(0 < option_edit, repo_get_index_file(the_repository),
+ NULL, "prepare-commit-msg",
git_path_merge_msg(the_repository), "merge", NULL))
abort_commit(remoteheads, NULL);
if (0 < option_edit) {
@@ -887,7 +891,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
abort_commit(remoteheads, NULL);
}
- if (!no_verify && run_commit_hook(0 < option_edit, get_index_file(),
+ if (!no_verify && run_commit_hook(0 < option_edit, repo_get_index_file(the_repository),
NULL, "commit-msg",
git_path_merge_msg(the_repository), NULL))
abort_commit(remoteheads, NULL);
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 8805cbbeb3..55289e989d 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -1,7 +1,6 @@
#include "builtin.h"
#include "abspath.h"
#include "config.h"
-#include "environment.h"
#include "gettext.h"
#include "parse-options.h"
#include "midx.h"
@@ -9,6 +8,7 @@
#include "trace2.h"
#include "object-store-ll.h"
#include "replace-object.h"
+#include "repository.h"
#define BUILTIN_MIDX_WRITE_USAGE \
N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]" \
@@ -63,7 +63,7 @@ static int parse_object_dir(const struct option *opt, const char *arg,
char **value = opt->value;
free(*value);
if (unset)
- *value = xstrdup(get_object_directory());
+ *value = xstrdup(repo_get_object_directory(the_repository));
else
*value = real_pathdup(arg, 1);
return 0;
diff --git a/builtin/notes.c b/builtin/notes.c
index 04f9dfb7fb..5d594a0724 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -897,6 +897,7 @@ static int merge(int argc, const char **argv, const char *prefix)
1, PARSE_OPT_NONEG),
OPT_END()
};
+ char *notes_ref;
argc = parse_options(argc, argv, prefix, options,
git_notes_merge_usage, 0);
@@ -924,7 +925,8 @@ static int merge(int argc, const char **argv, const char *prefix)
if (do_commit)
return merge_commit(&o);
- o.local_ref = default_notes_ref();
+ notes_ref = default_notes_ref(the_repository);
+ o.local_ref = notes_ref;
strbuf_addstr(&remote_ref, argv[0]);
expand_loose_notes_ref(&remote_ref);
o.remote_ref = remote_ref.buf;
@@ -953,7 +955,7 @@ static int merge(int argc, const char **argv, const char *prefix)
}
strbuf_addf(&msg, "notes: Merged notes from %s into %s",
- remote_ref.buf, default_notes_ref());
+ remote_ref.buf, notes_ref);
strbuf_add(&(o.commit_msg), msg.buf + 7, msg.len - 7); /* skip "notes: " */
result = notes_merge(&o, t, &result_oid);
@@ -961,7 +963,7 @@ static int merge(int argc, const char **argv, const char *prefix)
if (result >= 0) /* Merge resulted (trivially) in result_oid */
/* Update default notes ref with new commit */
refs_update_ref(get_main_ref_store(the_repository), msg.buf,
- default_notes_ref(), &result_oid, NULL, 0,
+ notes_ref, &result_oid, NULL, 0,
UPDATE_REFS_DIE_ON_ERR);
else { /* Merge has unresolved conflicts */
struct worktree **worktrees;
@@ -973,14 +975,14 @@ static int merge(int argc, const char **argv, const char *prefix)
/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
worktrees = get_worktrees();
wt = find_shared_symref(worktrees, "NOTES_MERGE_REF",
- default_notes_ref());
+ notes_ref);
if (wt)
die(_("a notes merge into %s is already in-progress at %s"),
- default_notes_ref(), wt->path);
+ notes_ref, wt->path);
free_worktrees(worktrees);
- if (refs_update_symref(get_main_ref_store(the_repository), "NOTES_MERGE_REF", default_notes_ref(), NULL))
+ if (refs_update_symref(get_main_ref_store(the_repository), "NOTES_MERGE_REF", notes_ref, NULL))
die(_("failed to store link to current notes ref (%s)"),
- default_notes_ref());
+ notes_ref);
fprintf(stderr, _("Automatic notes merge failed. Fix conflicts in %s "
"and commit the result with 'git notes merge --commit', "
"or abort the merge with 'git notes merge --abort'.\n"),
@@ -988,6 +990,7 @@ static int merge(int argc, const char **argv, const char *prefix)
}
free_notes(t);
+ free(notes_ref);
strbuf_release(&remote_ref);
strbuf_release(&msg);
return result < 0; /* return non-zero on conflicts */
@@ -1084,6 +1087,7 @@ static int prune(int argc, const char **argv, const char *prefix)
static int get_ref(int argc, const char **argv, const char *prefix)
{
struct option options[] = { OPT_END() };
+ char *notes_ref;
argc = parse_options(argc, argv, prefix, options,
git_notes_get_ref_usage, 0);
@@ -1092,7 +1096,9 @@ static int get_ref(int argc, const char **argv, const char *prefix)
usage_with_options(git_notes_get_ref_usage, options);
}
- puts(default_notes_ref());
+ notes_ref = default_notes_ref(the_repository);
+ puts(notes_ref);
+ free(notes_ref);
return 0;
}
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 01479a9ccc..657c589b08 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3968,7 +3968,7 @@ static int add_loose_object(const struct object_id *oid, const char *path,
*/
static void add_unreachable_loose_objects(void)
{
- for_each_loose_file_in_objdir(get_object_directory(),
+ for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
add_loose_object,
NULL, NULL, NULL);
}
diff --git a/builtin/prune.c b/builtin/prune.c
index 57fe31467f..47eeabbd13 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -193,12 +193,12 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
revs.exclude_promisor_objects = 1;
}
- for_each_loose_file_in_objdir(get_object_directory(), prune_object,
- prune_cruft, prune_subdir, &revs);
+ for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
+ prune_object, prune_cruft, prune_subdir, &revs);
prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);
- remove_temporary_files(get_object_directory());
- s = mkpathdup("%s/pack", get_object_directory());
+ remove_temporary_files(repo_get_object_directory(the_repository));
+ s = mkpathdup("%s/pack", repo_get_object_directory(the_repository));
remove_temporary_files(s);
free(s);
diff --git a/builtin/repack.c b/builtin/repack.c
index 3ee8cfa732..a4c0a7b97f 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1260,7 +1260,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (write_midx && write_bitmaps) {
struct strbuf path = STRBUF_INIT;
- strbuf_addf(&path, "%s/%s_XXXXXX", get_object_directory(),
+ strbuf_addf(&path, "%s/%s_XXXXXX", repo_get_object_directory(the_repository),
"bitmap-ref-tips");
refs_snapshot = xmks_tempfile(path.buf);
@@ -1269,7 +1269,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
strbuf_release(&path);
}
- packdir = mkpathdup("%s/pack", get_object_directory());
+ packdir = mkpathdup("%s/pack", repo_get_object_directory(the_repository));
packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
@@ -1539,7 +1539,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
unsigned flags = 0;
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
flags |= MIDX_WRITE_INCREMENTAL;
- write_midx_file(get_object_directory(), NULL, NULL, flags);
+ write_midx_file(repo_get_object_directory(the_repository),
+ NULL, NULL, flags);
}
cleanup:
diff --git a/builtin/replace.c b/builtin/replace.c
index 34cc4672bc..01161350b1 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -11,7 +11,6 @@
#include "builtin.h"
#include "config.h"
#include "editor.h"
-#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "refs.h"
@@ -514,7 +513,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
static int convert_graft_file(int force)
{
- const char *graft_file = get_graft_file(the_repository);
+ const char *graft_file = repo_get_graft_file(the_repository);
FILE *fp = fopen_or_warn(graft_file, "r");
struct strbuf buf = STRBUF_INIT, err = STRBUF_INIT;
struct strvec args = STRVEC_INIT;
diff --git a/builtin/reset.c b/builtin/reset.c
index 5f941fb3a2..86b2f07d66 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -26,6 +26,7 @@
#include "object-name.h"
#include "parse-options.h"
#include "path.h"
+#include "repository.h"
#include "unpack-trees.h"
#include "cache-tree.h"
#include "setup.h"
@@ -441,7 +442,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
else
trace2_cmd_mode(reset_type_names[reset_type]);
- if (reset_type != SOFT && (reset_type != MIXED || get_git_work_tree()))
+ if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository)))
setup_work_tree();
if (reset_type == MIXED && is_bare_repository())
@@ -474,7 +475,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
goto cleanup;
}
the_repository->index->updated_skipworktree = 1;
- if (!no_refresh && get_git_work_tree()) {
+ if (!no_refresh && repo_get_work_tree(the_repository)) {
uint64_t t_begin, t_delta_in_ms;
t_begin = getnanotime();
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4285dc34a7..34b4675442 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -19,6 +19,8 @@
#include "path.h"
#include "diff.h"
#include "read-cache-ll.h"
+#include "repo-settings.h"
+#include "repository.h"
#include "revision.h"
#include "setup.h"
#include "split-index.h"
@@ -898,7 +900,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
if (opt_with_value(arg, "--abbrev-ref", &arg)) {
abbrev_ref = 1;
- abbrev_ref_strict = warn_ambiguous_refs;
+ abbrev_ref_strict =
+ repo_settings_get_warn_ambiguous_refs(the_repository);
if (arg) {
if (!strcmp(arg, "strict"))
abbrev_ref_strict = 1;
@@ -966,7 +969,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--show-toplevel")) {
- const char *work_tree = get_git_work_tree();
+ const char *work_tree = repo_get_work_tree(the_repository);
if (work_tree)
print_path(work_tree, prefix, format, DEFAULT_UNMODIFIED);
else
@@ -991,7 +994,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
const char *pfx = prefix;
if (!is_inside_work_tree()) {
const char *work_tree =
- get_git_work_tree();
+ repo_get_work_tree(the_repository);
if (work_tree)
printf("%s\n", work_tree);
continue;
@@ -1042,7 +1045,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--git-common-dir")) {
- print_path(get_git_common_dir(), prefix, format, DEFAULT_RELATIVE_IF_SHARED);
+ print_path(repo_get_common_dir(the_repository), prefix, format, DEFAULT_RELATIVE_IF_SHARED);
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) {
diff --git a/builtin/stash.c b/builtin/stash.c
index 4a2a633ce3..c4252c0b5c 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -19,6 +19,7 @@
#include "entry.h"
#include "preload-index.h"
#include "read-cache.h"
+#include "repository.h"
#include "rerere.h"
#include "revision.h"
#include "setup.h"
@@ -539,8 +540,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
NULL, NULL, NULL))
return error(_("could not write index"));
- if (write_index_as_tree(&c_tree, the_repository->index, get_index_file(), 0,
- NULL))
+ if (write_index_as_tree(&c_tree, the_repository->index,
+ repo_get_index_file(the_repository), 0, NULL))
return error(_("cannot apply a stash in the middle of a merge"));
if (index) {
@@ -565,7 +566,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
discard_index(the_repository->index);
repo_read_index(the_repository);
if (write_index_as_tree(&index_tree, the_repository->index,
- get_index_file(), 0, NULL))
+ repo_get_index_file(the_repository), 0, NULL))
return error(_("could not save index tree"));
reset_head();
@@ -640,9 +641,9 @@ restore_untracked:
cp.git_cmd = 1;
cp.dir = prefix;
strvec_pushf(&cp.env, GIT_WORK_TREE_ENVIRONMENT"=%s",
- absolute_path(get_git_work_tree()));
+ absolute_path(repo_get_work_tree(the_repository)));
strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
- absolute_path(get_git_dir()));
+ absolute_path(repo_get_git_dir(the_repository)));
strvec_push(&cp.args, "status");
run_command(&cp);
}
@@ -1405,8 +1406,8 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
strbuf_addf(&commit_tree_label, "index on %s\n", msg.buf);
commit_list_insert(head_commit, &parents);
- if (write_index_as_tree(&info->i_tree, the_repository->index, get_index_file(), 0,
- NULL) ||
+ if (write_index_as_tree(&info->i_tree, the_repository->index,
+ repo_get_index_file(the_repository), 0, NULL) ||
commit_tree(commit_tree_label.buf, commit_tree_label.len,
&info->i_tree, parents, &info->i_commit, NULL, NULL)) {
if (!quiet)
@@ -1904,7 +1905,7 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
- index_file = get_index_file();
+ index_file = repo_get_index_file(the_repository);
strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file,
(uintmax_t)pid);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index e5ba05ab8c..9d8c4a3cee 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1709,7 +1709,7 @@ static int clone_submodule(const struct module_clone_data *clone_data,
exit(128);
if (!is_absolute_path(clone_data->path))
- clone_data_path = to_free = xstrfmt("%s/%s", get_git_work_tree(),
+ clone_data_path = to_free = xstrfmt("%s/%s", repo_get_work_tree(the_repository),
clone_data->path);
if (validate_submodule_git_dir(sm_gitdir, clone_data->name) < 0)
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 35a1f957ad..8baa225619 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1194,7 +1194,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
"remove or change it, if you really want to "
"enable the untracked cache"));
add_untracked_cache(the_repository->index);
- report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
+ report(_("Untracked cache enabled for '%s'"), repo_get_work_tree(the_repository));
break;
default:
BUG("bad untracked_cache value: %d", untracked_cache);
@@ -1239,7 +1239,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
if (newfd < 0) {
if (refresh_args.flags & REFRESH_QUIET)
exit(128);
- unable_to_lock_die(get_index_file(), lock_error);
+ unable_to_lock_die(repo_get_index_file(the_repository), lock_error);
}
if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
die("Unable to write new index file");
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 41e7f6a327..645b548bf3 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -219,7 +219,7 @@ static void prune_worktrees(void)
}
closedir(dir);
- strbuf_add_absolute_path(&main_path, get_git_common_dir());
+ strbuf_add_absolute_path(&main_path, repo_get_common_dir(the_repository));
/* massage main worktree absolute path to match 'gitdir' content */
strbuf_strip_suffix(&main_path, "/.");
string_list_append_nodup(&kept, strbuf_detach(&main_path, NULL));
@@ -492,7 +492,7 @@ static int add_worktree(const char *path, const char *refname,
strbuf_addf(&sb, "%s/gitdir", sb_repo.buf);
strbuf_realpath(&realpath, sb_git.buf, 1);
write_file(sb.buf, "%s", realpath.buf);
- strbuf_realpath(&realpath, get_git_common_dir(), 1);
+ strbuf_realpath(&realpath, repo_get_common_dir(the_repository), 1);
write_file(sb_git.buf, "gitdir: %s/worktrees/%s",
realpath.buf, name);
strbuf_reset(&sb);
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 8c75b4609b..9bcc4470ce 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -6,7 +6,6 @@
#include "builtin.h"
#include "config.h"
-#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "tree.h"
@@ -44,7 +43,8 @@ int cmd_write_tree(int argc, const char **argv, const char *cmd_prefix)
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
- ret = write_index_as_tree(&oid, the_repository->index, get_index_file(),
+ ret = write_index_as_tree(&oid, the_repository->index,
+ repo_get_index_file(the_repository),
flags, tree_prefix);
switch (ret) {
case 0: