[GSoC PATCH v5 3/5] repo: add field layout.bare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit is part of the series that introduces the new subcommand
git-repo-info.

The flag --is-bare-repository from git-rev-parse is used for retrieving
whether the current repository is bare. This way, it is used for
querying repository metadata, fitting in the purpose of git-repo-info.

Then, add a new field layout.bare to the git-repo-info subcommand
containing that information.

Helped-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
Helped-by: Junio C Hamano <gitster@xxxxxxxxx>
Helped-by: Justin Tobler <jltobler@xxxxxxxxx>
Mentored-by: Karthik Nayak <karthik.188@xxxxxxxxx>
Mentored-by: Patrick Steinhardt <ps@xxxxxx>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@xxxxxxxxx>
---
 Documentation/git-repo.adoc | 4 ++++
 builtin/repo.c              | 9 +++++++++
 t/t1900-repo.sh             | 6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index cf8483ec49..7124487323 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -33,6 +33,10 @@ categories:
 Reference-related data:
 * `format`: the reference storage format
 
+`layout`::
+Information about the how the current repository is represented:
+* `bare`: `true` if this is a bare repository, otherwise `false`.
+
 SEE ALSO
 --------
 linkgit:git-rev-parse[1]
diff --git a/builtin/repo.c b/builtin/repo.c
index 5beae0f781..b85bd10889 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -1,6 +1,9 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "builtin.h"
 #include "parse-options.h"
 #include "refs.h"
+#include "environment.h"
 
 typedef const char *get_value_fn(struct repository *repo);
 
@@ -9,6 +12,11 @@ struct field {
 	get_value_fn *add_field_callback;
 };
 
+static const char *get_layout_bare(struct repository *repo UNUSED)
+{
+	return is_bare_repository() ? "true" : "false";
+}
+
 static const char *get_references_format(struct repository *repo)
 {
 	return ref_storage_format_to_name(repo->ref_storage_format);
@@ -16,6 +24,7 @@ static const char *get_references_format(struct repository *repo)
 
 /* repo_info_fields keys should be in lexicographical order */
 static const struct field repo_info_fields[] = {
+	{ "layout.bare", get_layout_bare },
 	{ "references.format", get_references_format },
 };
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index f072c7c67b..03609ffff9 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -36,6 +36,12 @@ test_repo_info 'ref format files is retrieved correctly' '
 test_repo_info 'ref format reftable is retrieved correctly' '
 	git init --ref-format=reftable repo' 'references.format' 'reftable'
 
+test_repo_info 'bare repository = false is retrieved correctly' '
+	git init repo' 'layout.bare' 'false'
+
+test_repo_info 'bare repository = true is retrieved correctly' '
+	git init --bare repo' 'layout.bare' 'true'
+
 test_expect_success "only one value is returned if the same key is requested twice" '
 	test_when_finished "rm -f expected_key expected_value actual_key actual_value output" &&
 	echo "references.format" >expected_key &&
-- 
2.39.5 (Apple Git-154)





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux