environment: make get_git_dir() accept a repository
The `get_git_dir()` function retrieves the path to the Git directory for `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
17d4b10aea
commit
246deeac95
@@ -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"));
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user