`layout.bare`::
`true` if this is a bare repository, otherwise `false`.
+`layout.shallow`::
+ `true` if this is a shallow repository, otherwise `false`.
+
`references.format`::
The reference storage format. The valid values are:
+
#include "quote.h"
#include "refs.h"
#include "strbuf.h"
+#include "shallow.h"
static const char *const repo_usage[] = {
"git repo info [<key>...]",
return 0;
}
+static int get_layout_shallow(struct repository *repo, struct strbuf *buf)
+{
+ strbuf_addstr(buf,
+ is_repository_shallow(repo) ? "true" : "false");
+ return 0;
+}
+
static int get_references_format(struct repository *repo, struct strbuf *buf)
{
strbuf_addstr(buf,
/* repo_info_fields keys must be in lexicographical order */
static const struct field repo_info_fields[] = {
{ "layout.bare", get_layout_bare },
+ { "layout.shallow", get_layout_shallow },
{ "references.format", get_references_format },
};
test_repo_info 'bare repository = true is retrieved correctly' \
'git init --bare' 'bare' 'layout.bare' 'true'
+test_repo_info 'shallow repository = false is retrieved correctly' \
+ 'git init' 'nonshallow' 'layout.shallow' 'false'
+
+test_expect_success 'setup remote' '
+ git init remote &&
+ echo x >remote/x &&
+ git -C remote add x &&
+ git -C remote commit -m x
+'
+
+test_repo_info 'shallow repository = true is retrieved correctly' \
+ 'git clone --depth 1 "file://$PWD/remote"' 'shallow' 'layout.shallow' 'true'
+
test_expect_success 'values returned in order requested' '
cat >expect <<-\EOF &&
layout.bare=false