On 25/07/14 08:52PM, Lucas Seiki Oshiro wrote: > This commit is part of the series that introduce the new subcommand s/introduce/introduces/ > git-repo-info. > > The flag `--show-ref-format` from git-rev-parse is used for retrieving > the reference format (i.e. `files` or `reftable`). This way, it is > used for querying repository metadata, fitting in the purpose of > git-repo-info. > > Then, add a new field `references.format` to the 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 | 92 +++++++++++++++++++++++++++++++++++-- > t/meson.build | 1 + > t/t1900-repo.sh | 47 +++++++++++++++++++ > 4 files changed, 140 insertions(+), 4 deletions(-) > create mode 100755 t/t1900-repo.sh > > diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc > index 6f8fe3f6ea..b7af6f45a4 100644 > --- a/Documentation/git-repo.adoc > +++ b/Documentation/git-repo.adoc > @@ -45,6 +45,10 @@ INFO KEYS > The set of data that `git repo` can return is grouped into the following > categories: > > +`references`:: > +Reference-related data: > +* `format`: the reference storage format, either `files` or `reftable`. > + > SEE ALSO > -------- > linkgit:git-rev-parse[1] > diff --git a/builtin/repo.c b/builtin/repo.c > index a1787a3cc5..dcda0d6d61 100644 > --- a/builtin/repo.c > +++ b/builtin/repo.c > @@ -1,11 +1,95 @@ > #include "builtin.h" > #include "parse-options.h" > +#include "strbuf.h" > +#include "refs.h" > > -static int repo_info(int argc UNUSED, > - const char **argv UNUSED, > +typedef void add_field_fn(struct strbuf *buf, struct repository *repo); > + > +struct field { > + const char *key; > + add_field_fn *add_field_callback; > +}; > + > +static void add_string(struct strbuf *buf, > + const char *key, const char *value) > +{ > + strbuf_addf(buf, "%s\n%s%c", key, value, '\0'); > +} Any reason we add each key/value pair to a buffer instead of just printing it? Also, as mentioned in a comment for the previous patch, maybe we should support printing two output modes. For the default output, maybe a simple `<key>=<value>\n` where the any value containing special characters is quoted via `quote_c_style()`. A null-terminated output, such as the one proposed in this patch, could be enabled via a `-z` flag similar to how its done in other commands. -Justin