public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
To: git@vger•kernel.org
Cc: ps@pks•im, karthik.188@gmail•com, gitster@pobox•com,
	Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Subject: [GSoC PATCH v3 2/2] repo: add the field objects.format
Date: Mon,  1 Sep 2025 14:27:32 -0300	[thread overview]
Message-ID: <20250901172732.98845-3-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250901172732.98845-1-lucasseikioshiro@gmail.com>

The flag `--show-object-format` from git-rev-parse is used for
retrieving the object storage format. This way, it is used for
querying repository metadata, fitting in the purpose of git-repo-info.

Add a new field `objects.format` to the git-repo-info subcommand
containing that information.

Mentored-by: Karthik Nayak <karthik.188@gmail•com>
Mentored-by: Patrick Steinhardt <ps@pks•im>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
---
 Documentation/git-repo.adoc | 3 +++
 builtin/repo.c              | 7 +++++++
 t/t1900-repo.sh             | 6 ++++++
 3 files changed, 16 insertions(+)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 6f5ee88215..209afd1b61 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -55,6 +55,9 @@ values that they return:
 `layout.shallow`::
 	`true` if this is a shallow repository, otherwise `false`.
 
+`object.format`::
+	The object format (hash algorithm) used in the repository.
+
 `references.format`::
 	The reference storage format. The valid values are:
 +
diff --git a/builtin/repo.c b/builtin/repo.c
index 13a34f68a5..9b519426fe 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -38,6 +38,12 @@ static int get_layout_shallow(struct repository *repo, struct strbuf *buf)
 	return 0;
 }
 
+static int get_object_format(struct repository *repo, struct strbuf *buf)
+{
+	strbuf_addstr(buf, repo->hash_algo->name);
+	return 0;
+}
+
 static int get_references_format(struct repository *repo, struct strbuf *buf)
 {
 	strbuf_addstr(buf,
@@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)
 static const struct field repo_info_fields[] = {
 	{ "layout.bare", get_layout_bare },
 	{ "layout.shallow", get_layout_shallow },
+	{ "object.format", get_object_format },
 	{ "references.format", get_references_format },
 };
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index ddf788d5a2..2beba67889 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -63,6 +63,12 @@ test_expect_success 'setup remote' '
 test_repo_info 'shallow repository = true is retrieved correctly' \
 	'git clone --depth 1 "file://$PWD/remote"' 'shallow' 'layout.shallow' 'true'
 
+test_repo_info 'object.format = sha1 is retrieved correctly' \
+	'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'
+
+test_repo_info 'object.format = sha256 is retrieved correctly' \
+	'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'
+
 test_expect_success 'values returned in order requested' '
 	cat >expect <<-\EOF &&
 	layout.bare=false
-- 
2.39.5 (Apple Git-154)


  parent reply	other threads:[~2025-09-01 17:27 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 14:42 [GSoC PATCH 0/2] repo: add -z and objects.format Lucas Seiki Oshiro
2025-08-20 14:42 ` [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-08-21 10:12   ` Karthik Nayak
2025-08-21 16:09     ` Junio C Hamano
2025-08-21 16:52       ` Karthik Nayak
2025-08-21 10:29   ` Patrick Steinhardt
2025-08-21 13:29     ` Lucas Seiki Oshiro
2025-08-21 17:28       ` Junio C Hamano
2025-08-21 20:57         ` Lucas Seiki Oshiro
2025-08-21 21:50           ` Junio C Hamano
2025-08-21 18:23   ` Jean-Noël AVILA
2025-08-21 19:52     ` Junio C Hamano
2025-08-20 14:42 ` [GSoC PATCH 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-08-21 10:29   ` Patrick Steinhardt
2025-08-21 19:44   ` Junio C Hamano
2025-08-26 14:51     ` Lucas Seiki Oshiro
2025-08-21 10:14 ` [GSoC PATCH 0/2] repo: add -z and objects.format Karthik Nayak
2025-08-21 16:12   ` Junio C Hamano
2025-08-21 10:29 ` Patrick Steinhardt
2025-08-21 13:23   ` Lucas Seiki Oshiro
2025-08-21 14:55     ` Patrick Steinhardt
2025-08-21 17:28     ` Junio C Hamano
2025-08-26 18:13       ` Lucas Seiki Oshiro
2025-08-26 18:32 ` [GSoC PATCH v2 " Lucas Seiki Oshiro
2025-08-26 18:32   ` [GSoC PATCH v2 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-08-28 23:08     ` Junio C Hamano
2025-09-01 13:50       ` Lucas Seiki Oshiro
2025-08-26 18:32   ` [GSoC PATCH v2 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-09-01 17:27 ` [GSoC PATCH v3 0/2] repo: add -z and objects.format Lucas Seiki Oshiro
2025-09-01 17:27   ` [GSoC PATCH v3 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-09-02 16:21     ` Junio C Hamano
2025-09-02 21:51       ` Lucas Seiki Oshiro
2025-09-01 17:27   ` Lucas Seiki Oshiro [this message]
2025-09-04 13:40 ` [GSoC PATCH v4 0/2] repo: add -z and objects.format Lucas Seiki Oshiro
2025-09-04 13:40   ` [GSoC PATCH v4 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-09-04 13:40   ` [GSoC PATCH v4 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-09-04 18:40   ` [GSoC PATCH v4 0/2] repo: add -z and objects.format Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250901172732.98845-3-lucasseikioshiro@gmail.com \
    --to=lucasseikioshiro@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=karthik.188@gmail$(echo .)com \
    --cc=ps@pks$(echo .)im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox