git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[GSoC PATCH 2/2] repo: add the field objects.format

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Aug 20, 2025, 14:42 UTC
Message-ID
<20250820144247.79197-3-lucasseikioshiro@gmail.com>
In-Reply-To
<20250820144247.79197-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 f2dc71193c..b6ec423d12 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`.
 
+`objects.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 b2ec66e454..71ddc5e8c6 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_objects_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 },
+	{ "objects.format", get_objects_format},
 	{ "references.format", get_references_format },
 };
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 3df55dcc79..aca2ed23f9 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 'objects.format = sha1 is retrieved correctly' \
+	'git init --object-format=sha1' 'sha1' 'objects.format' 'sha1'
+
+test_repo_info 'objects.format = sha256 is retrieved correctly' \
+	'git init --object-format=sha256' 'sha256' 'objects.format' 'sha256'
+
 test_expect_success 'values returned in order requested' '
 	cat >expect <<-\EOF &&
 	layout.bare=false
-- 
2.39.5 (Apple Git-154)
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 13 of 37 in “repo: add -z and objects.format”
  1. 0/2 repo: add -z and objects.formatLucas Seiki Oshiro, Aug 20, 2025
  2. 1/2 repo: add the flag -z as an alias for --format=nulLucas Seiki Oshiro, Aug 20, 2025
  3. Karthik NayakAug 21, 2025
  4. Junio C HamanoAug 21, 2025
  5. Karthik NayakAug 21, 2025
  6. Patrick SteinhardtAug 21, 2025
  7. Lucas Seiki OshiroAug 21, 2025
  8. Junio C HamanoAug 21, 2025
  9. Lucas Seiki OshiroAug 21, 2025
  10. Junio C HamanoAug 21, 2025
  11. Jean-Noël AVILAAug 21, 2025
  12. Junio C HamanoAug 21, 2025
  13. 2/2 repo: add the field objects.formatLucas Seiki Oshiro, Aug 20, 2025
  14. Patrick SteinhardtAug 21, 2025
  15. Junio C HamanoAug 21, 2025
  16. Lucas Seiki OshiroAug 26, 2025
  17. Karthik NayakAug 21, 2025
  18. Junio C HamanoAug 21, 2025
  19. Patrick SteinhardtAug 21, 2025
  20. Lucas Seiki OshiroAug 21, 2025
  21. Patrick SteinhardtAug 21, 2025
  22. Junio C HamanoAug 21, 2025
  23. Lucas Seiki OshiroAug 26, 2025
  24. 0/2 repo: add -z and objects.formatLucas Seiki Oshiro, Aug 26, 2025
  25. 1/2 repo: add the flag -z as an alias for --format=nulLucas Seiki Oshiro, Aug 26, 2025
  26. Junio C HamanoAug 28, 2025
  27. Lucas Seiki OshiroSep 1, 2025
  28. 2/2 repo: add the field objects.formatLucas Seiki Oshiro, Aug 26, 2025
  29. 0/2 repo: add -z and objects.formatLucas Seiki Oshiro, Sep 1, 2025
  30. 1/2 repo: add the flag -z as an alias for --format=nulLucas Seiki Oshiro, Sep 1, 2025
  31. Junio C HamanoSep 2, 2025
  32. Lucas Seiki OshiroSep 2, 2025
  33. 2/2 repo: add the field objects.formatLucas Seiki Oshiro, Sep 1, 2025
  34. 0/2 repo: add -z and objects.formatLucas Seiki Oshiro, Sep 4, 2025
  35. 1/2 repo: add the flag -z as an alias for --format=nulLucas Seiki Oshiro, Sep 4, 2025
  36. 2/2 repo: add the field objects.formatLucas Seiki Oshiro, Sep 4, 2025
  37. Junio C HamanoSep 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.