Git fork

repo: add the field objects.format

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Lucas Seiki Oshiro and committed by
Junio C Hamano
c2e37133 a92f5ca0

+16
+3
Documentation/git-repo.adoc
··· 55 55 `layout.shallow`:: 56 56 `true` if this is a shallow repository, otherwise `false`. 57 57 58 + `object.format`:: 59 + The object format (hash algorithm) used in the repository. 60 + 58 61 `references.format`:: 59 62 The reference storage format. The valid values are: 60 63 +
+7
builtin/repo.c
··· 38 38 return 0; 39 39 } 40 40 41 + static int get_object_format(struct repository *repo, struct strbuf *buf) 42 + { 43 + strbuf_addstr(buf, repo->hash_algo->name); 44 + return 0; 45 + } 46 + 41 47 static int get_references_format(struct repository *repo, struct strbuf *buf) 42 48 { 43 49 strbuf_addstr(buf, ··· 49 55 static const struct field repo_info_fields[] = { 50 56 { "layout.bare", get_layout_bare }, 51 57 { "layout.shallow", get_layout_shallow }, 58 + { "object.format", get_object_format }, 52 59 { "references.format", get_references_format }, 53 60 }; 54 61
+6
t/t1900-repo.sh
··· 63 63 test_repo_info 'shallow repository = true is retrieved correctly' \ 64 64 'git clone --depth 1 "file://$PWD/remote"' 'shallow' 'layout.shallow' 'true' 65 65 66 + test_repo_info 'object.format = sha1 is retrieved correctly' \ 67 + 'git init --object-format=sha1' 'sha1' 'object.format' 'sha1' 68 + 69 + test_repo_info 'object.format = sha256 is retrieved correctly' \ 70 + 'git init --object-format=sha256' 'sha256' 'object.format' 'sha256' 71 + 66 72 test_expect_success 'values returned in order requested' ' 67 73 cat >expect <<-\EOF && 68 74 layout.bare=false