Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Documentation/git-repo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ In order to obtain a set of values from `git repo info`, you should provide
the keys that identify them. Here's a list of the available keys and the
values that they return:

`paths.git_dir`::
The path to the Git directory for the repository (equivalent to
`git rev-parse --git-dir`).


`layout.bare`::
`true` if this is a bare repository, otherwise `false`.

Expand Down
7 changes: 7 additions & 0 deletions builtin/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,18 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)
return 0;
}

static int get_paths_git_dir(struct repository *repo, struct strbuf *buf)
{
strbuf_addstr(buf, repo_get_git_dir(repo));
return 0;
}

/* repo_info_field keys must be in lexicographical order */
static const struct repo_info_field repo_info_field[] = {
{ "layout.bare", get_layout_bare },
{ "layout.shallow", get_layout_shallow },
{ "object.format", get_object_format },
{ "paths.git_dir", get_paths_git_dir },
{ "references.format", get_references_format },
};

Expand Down
10 changes: 10 additions & 0 deletions t/t1900-repo-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,14 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
test_cmp expect actual
'

test_expect_success 'paths.git_dir matches rev-parse --git-dir' '
git init repo &&
(
cd repo &&
git repo info paths.git_dir >actual &&
echo "paths.git_dir=$(git rev-parse --git-dir)" >expect &&
test_cmp expect actual
)
'

test_done
Loading