environment: make get_index_file()
accept a repository
The `get_index_file()` function retrieves the path to the index file of `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a3673f4898
commit
1dc4ec2102
@ -696,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"));
|
||||
}
|
||||
|
||||
@ -758,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,
|
||||
@ -840,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;
|
||||
@ -880,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) {
|
||||
@ -889,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);
|
||||
|
Reference in New Issue
Block a user