The path to the repository's hooks directory relative to the current
working directory. Respects `core.hooksPath` configuration adjustments.
+`path.index.absolute`::
+ The canonical absolute path to the repository's current index file.
+ Respects the `GIT_INDEX_FILE` environment override. The returned path
+ reflects the configured/default index location regardless of whether the
+ repository is bare or whether the file currently exists.
+
+`path.index.relative`::
+ The path to the repository's current index file relative to the current
+ working directory. Respects the `GIT_INDEX_FILE` environment override.
+ The returned path reflects the configured/default index location regardless
+ of whether the repository is bare or whether the file currently exists.
+
`path.objects.absolute`::
The canonical absolute path to the repository's object database directory.
Respects the `GIT_OBJECT_DIRECTORY` environment override.
return 0;
}
+static int get_path_index_absolute(struct repository *repo, struct strbuf *buf)
+{
+ const char *index_file = repo_get_index_file(repo);
+
+ if (!index_file)
+ return error(_("unable to get index file"));
+
+ format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_CANONICAL);
+ return 0;
+}
+
+static int get_path_index_relative(struct repository *repo, struct strbuf *buf)
+{
+ const char *index_file = repo_get_index_file(repo);
+
+ if (!index_file)
+ return error(_("unable to get index file"));
+
+ format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_RELATIVE);
+ return 0;
+}
+
static int get_path_objects_absolute(struct repository *repo, struct strbuf *buf)
{
const char *obj_dir = repo_get_object_directory(repo);
{ "path.gitdir.relative", get_path_gitdir_relative },
{ "path.hooks.absolute", get_path_hooks_absolute },
{ "path.hooks.relative", get_path_hooks_relative },
+ { "path.index.absolute", get_path_index_absolute },
+ { "path.index.relative", get_path_index_relative },
{ "path.objects.absolute", get_path_objects_absolute },
{ "path.objects.relative", get_path_objects_relative },
{ "path.superproject-working-tree.absolute", get_path_superproject_absolute },
'custom-hooks' \
'git config core.hooksPath "$ROOT/custom-hooks" && mkdir -p "$ROOT/custom-hooks"'
+test_repo_info_path 'index standard' 'index' '.git/index'
+
+test_repo_info_path 'index with GIT_INDEX_FILE override' 'index' \
+ 'custom-index-file' \
+ 'GIT_INDEX_FILE="$ROOT/custom-index-file" && export GIT_INDEX_FILE'
+
+test_expect_success 'path.index in a bare repository returns default index location' '
+ test_when_finished "rm -rf bare.git" &&
+ git init --bare bare.git &&
+ (
+ cd bare.git &&
+ ROOT="$(test-tool path-utils real_path .)" &&
+
+ echo "path.index.absolute=$ROOT/index" >expect.abs &&
+ git repo info path.index.absolute >actual.abs &&
+ test_cmp expect.abs actual.abs &&
+
+ echo "path.index.relative=index" >expect.rel &&
+ git repo info path.index.relative >actual.rel &&
+ test_cmp expect.rel actual.rel
+ )
+'
+
test_repo_info_path 'objects standard' 'objects' '.git/objects'
test_repo_info_path 'objects with GIT_OBJECT_DIRECTORY override' 'objects' \