git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
To: git@vger.kernel.org
Cc: oswald.buddenhagen@gmx.de, ps@pks.im, karthik.188@gmail.com,
	ben.knoble@gmail.com, gitster@pobox.com,
	phillip.wood@dunelm.org.uk, jltobler@gmail.com, jn.avila@free.fr,
	sunshine@sunshineco.com,
	Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Subject: [GSoC PATCH v7 0/5] repo: add new command for retrieving repository info
Date: Fri,  1 Aug 2025 10:11:05 -0300	[thread overview]
Message-ID: <20250801131111.8115-1-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250610152117.14826-1-lucasseikioshiro@gmail.com>

Hi!

These are the changes of this 7th version of `git repo`:

- The tests were refactored (thanks Eric for your careful revision!)

- The documentation has been improved: now it is a little more
  descriptive about the keys. I'm also including more information about
  the values

- The documentation now contains examples

- If an invalid key is requested, the command fails, however, now it
  returns all the valid fields that were requested

- Now, I'm using `quote_c_style` in the key=value format

Thanks!

Range-diff versus v6:

1:  bc6f19ba8e ! 1:  b4f063b177 repo: declare the repo command
    @@ Commit message
         will bring the functionality of retrieving repository-related
         information currently returned by `rev-parse`.

    -    Add the required tests, documentation and build changes to enable
    -    usage of this subcommand.
    +    Add the required documentation and build changes to enable usage of
    +    this subcommand.

         Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
         Helped-by: Junio C Hamano <gitster@pobox.com>
         Helped-by: Justin Tobler <jltobler@gmail.com>
    +    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
         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 (new)
     +
     +NAME
     +----
    -+git-repo - Retrieve information about a repository
    ++git-repo - Retrieve information about the repository
     +
     +SYNOPSIS
     +--------
    @@ Documentation/git-repo.adoc (new)
     +
     +DESCRIPTION
     +-----------
    -+This command retrieve repository level information.
    ++Retrieve information about the repository.
     +
     +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
     +
    @@ Documentation/git-repo.adoc (new)
     +	the requested data will be returned based on their keys (see "INFO KEYS"
     +	section below).
     +
    -+INFO KEYS
    -+---------
    -+
    -+The set of data that `git repo` can return is grouped into the following
    -+categories:
    -+
     +SEE ALSO
     +--------
     +linkgit:git-rev-parse[1]
    @@ builtin/repo.c (new)
     +#include "builtin.h"
     +#include "parse-options.h"
     +
    ++static const char *const repo_usage[] = {
    ++	"git repo info [<key>...]",
    ++	NULL
    ++};
    ++
     +static int repo_info(int argc UNUSED, const char **argv UNUSED,
     +		     const char *prefix UNUSED, struct repository *repo UNUSED)
     +{
    @@ builtin/repo.c (new)
     +	     struct repository *repo)
     +{
     +	parse_opt_subcommand_fn *fn = NULL;
    -+	const char *const repo_usage[] = {
    -+		"git repo info [<key>...]",
    -+		NULL
    -+	};
     +	struct option options[] = {
     +		OPT_SUBCOMMAND("info", &fn, repo_info),
     +		OPT_END()
2:  2b0e91f94d ! 2:  56cb05ecb2 repo: add the field references.format
    @@ Commit message
         Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
         Helped-by: Junio C Hamano <gitster@pobox.com>
         Helped-by: Justin Tobler <jltobler@gmail.com>
    +    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
         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 ##
    -@@ Documentation/git-repo.adoc: INFO KEYS
    - The set of data that `git repo` can return is grouped into the following
    - categories:
    +@@ Documentation/git-repo.adoc: COMMANDS
    + 	Retrieve metadata-related information about the current repository. Only
    + 	the requested data will be returned based on their keys (see "INFO KEYS"
    + 	section below).
    +++
    ++The returned data is lexicographically sorted by the keys.
    ++
    ++INFO KEYS
    ++---------
    ++
    ++In order to obtain a set of values from `git repo info`, you should provide
    ++the keys that identify them. Here's a list of the available keys and the
    ++values that they return:
    ++
    ++`references.format`::
    ++The reference storage format. The valid values are:
    +++
    ++include::ref-storage-format.adoc[]

    -+`references`::
    -+Reference-related data:
    -+* `format`: the reference storage format
    -+
      SEE ALSO
      --------
    - linkgit:git-rev-parse[1]

      ## builtin/repo.c ##
     @@
      #include "builtin.h"
      #include "parse-options.h"
    ++#include "quote.h"
     +#include "refs.h"
     +#include "strbuf.h"

    + static const char *const repo_usage[] = {
    + 	"git repo info [<key>...]",
    + 	NULL
    + };
    +
     -static int repo_info(int argc UNUSED, const char **argv UNUSED,
     -		     const char *prefix UNUSED, struct repository *repo UNUSED)
     +typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
    @@ builtin/repo.c
     +};
     +
     +static int get_references_format(struct repository *repo, struct strbuf *buf)
    -+{
    + {
     +	strbuf_addstr(buf,
     +		      ref_storage_format_to_name(repo->ref_storage_format));
    -+	return 0;
    -+}
    -+
    + 	return 0;
    + }
    +
     +/* repo_info_fields keys should be in lexicographical order */
     +static const struct field repo_info_fields[] = {
     +	{ "references.format", get_references_format },
    @@ builtin/repo.c
     +}
     +
     +static int qsort_strcmp(const void *va, const void *vb)
    - {
    ++{
     +	const char *a = *(const char **)va;
     +	const char *b = *(const char **)vb;
     +
    @@ builtin/repo.c
     +
     +static int print_fields(int argc, const char **argv, struct repository *repo)
     +{
    ++	int ret = 0;
     +	const char *last = "";
    ++	struct strbuf sb = STRBUF_INIT;
     +
     +	QSORT(argv, argc, qsort_strcmp);
     +
     +	for (int i = 0; i < argc; i++) {
     +		get_value_fn *get_value;
     +		const char *key = argv[i];
    -+		struct strbuf value;
    ++		char *value;
     +
     +		if (!strcmp(key, last))
     +			continue;
     +
    -+		strbuf_init(&value, 64);
     +		get_value = get_value_fn_for_key(key);
     +
     +		if (!get_value) {
    -+			strbuf_release(&value);
    -+			return error(_("key '%s' not found"), key);
    ++			ret = error(_("key '%s' not found"), key);
    ++			continue;
     +		}
     +
    -+		get_value(repo, &value);
    -+		printf("%s=%s\n", key, value.buf);
    ++		strbuf_reset(&sb);
    ++		get_value(repo, &sb);
    ++
    ++		value = strbuf_detach(&sb, NULL);
    ++		quote_c_style(value, &sb, NULL, 0);
    ++		free(value);
    ++
    ++		printf("%s=%s\n", key, sb.buf);
     +		last = key;
    -+		strbuf_release(&value);
     +	}
     +
    - 	return 0;
    - }
    -
    ++	strbuf_release(&sb);
    ++	return ret;
    ++}
    ++
     +static int repo_info(int argc, const char **argv, const char *prefix UNUSED,
     +		     struct repository *repo)
     +{
    @@ t/t1900-repo.sh (new)
     +
     +. ./test-lib.sh
     +
    -+# Test if a field is correctly returned in the null-terminated format
    ++# Test whether a key-value pair is correctly returned
     +#
     +# Usage: test_repo_info <label> <init command> <key> <expected value>
     +#
     +# Arguments:
     +#   label: the label of the test
    -+#   init command: a command that creates a repository called 'repo', configured
    ++#   init command: a command which creates a repository named with its first argument,
     +#      accordingly to what is being tested
     +#   key: the key of the field that is being tested
     +#   expected value: the value that the field should contain
     +test_repo_info () {
     +	label=$1
     +	init_command=$2
    -+	key=$3
    -+	expected_value=$4
    ++	repo_name=$3
    ++	key=$4
    ++	expected_value=$5
     +
     +	test_expect_success "$label" '
    -+		test_when_finished "rm -rf repo" &&
    -+		eval "$init_command" &&
    -+		echo "$expected_value" >expected &&
    -+		git -C repo repo info "$key" >output &&
    -+		cut -d "=" -f 2 <output >actual &&
    ++		eval "$init_command $repo_name" &&
    ++		echo "$key=$expected_value" >expected &&
    ++		git -C $repo_name repo info "$key" >actual &&
     +		test_cmp expected actual
     +	'
     +}
     +
     +test_repo_info 'ref format files is retrieved correctly' '
    -+	git init --ref-format=files repo' 'references.format' 'files'
    ++	git init --ref-format=files' 'format-files' 'references.format' 'files'
     +
     +test_repo_info 'ref format reftable is retrieved correctly' '
    -+	git init --ref-format=reftable repo' 'references.format' 'reftable'
    ++	git init --ref-format=reftable' 'format-reftable' 'references.format' 'reftable'
    ++
    ++test_expect_success 'git-repo-info fails if an invalid key is requested' '
    ++	echo "error: key '\'foo\'' not found" >expected_err &&
    ++	test_must_fail git repo info foo 2>actual_err &&
    ++	test_cmp expected_err actual_err
    ++'
     +
    -+test_expect_success 'git-repo-info aborts if an invalid key is requested' '
    -+	test_when_finished "rm -rf expected err" &&
    -+	echo "error: key '\'foo\'' not found" >expected &&
    -+	test_must_fail git repo info foo 2>err &&
    -+	test_cmp expected err
    ++test_expect_success 'git-repo-info outputs data even if there is an invalid field' '
    ++	echo "references.format=files" >expected &&
    ++	test_must_fail git repo info foo references.format bar >actual &&
    ++	test_cmp expected actual
     +'
     +
    -+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 &&
    -+	git rev-parse --show-ref-format >expected_value &&
    -+	git repo info references.format references.format >output &&
    -+	cut -d "=" -f 1 <output >actual_key &&
    -+	cut -d "=" -f 2 <output >actual_value &&
    -+        test_cmp expected_key actual_key &&
    -+        test_cmp expected_value actual_value
    ++test_expect_success 'only one value is returned if the same key is requested twice' '
    ++	val=$(git rev-parse --show-ref-format) &&
    ++	echo "references.format=$val" >expect &&
    ++	git repo info references.format references.format >actual &&
    ++	test_cmp expect actual
     +'
     +
     +test_done
3:  733d3533d8 ! 3:  fc4c70d9b7 repo: add field layout.bare
    @@ Metadata
     Author: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>

      ## Commit message ##
    -    repo: add field layout.bare
    +    repo: add the field layout.bare

         This commit is part of the series that introduces the new subcommand
         git-repo-info.
    @@ Commit message
         Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
         Helped-by: Junio C Hamano <gitster@pobox.com>
         Helped-by: Justin Tobler <jltobler@gmail.com>
    +    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
         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 ##
    -@@ Documentation/git-repo.adoc: categories:
    - Reference-related data:
    - * `format`: the reference storage format
    +@@ Documentation/git-repo.adoc: In order to obtain a set of values from `git repo info`, you should provide
    + the keys that identify them. Here's a list of the available keys and the
    + values that they return:

    -+`layout`::
    -+Information about the how the current repository is represented:
    -+* `bare`: `true` if this is a bare repository, otherwise `false`.
    ++`layout.bare`::
    ++`true` if this is a bare repository, otherwise `false`.
     +
    - SEE ALSO
    - --------
    - linkgit:git-rev-parse[1]
    + `references.format`::
    + The reference storage format. The valid values are:
    + +

      ## builtin/repo.c ##
     @@
    @@ builtin/repo.c
      #include "builtin.h"
     +#include "environment.h"
      #include "parse-options.h"
    + #include "quote.h"
      #include "refs.h"
    - #include "strbuf.h"
     @@ builtin/repo.c: struct field {
      	get_value_fn *get_value;
      };
    @@ builtin/repo.c: static int get_references_format(struct repository *repo, struct
      ## t/t1900-repo.sh ##
     @@ t/t1900-repo.sh: 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'
    + 	git init --ref-format=reftable' 'format-reftable' 'references.format' 'reftable'

     +test_repo_info 'bare repository = false is retrieved correctly' '
    -+	git init repo' 'layout.bare' 'false'
    ++	git init' 'bare' 'layout.bare' 'false'
     +
     +test_repo_info 'bare repository = true is retrieved correctly' '
    -+	git init --bare repo' 'layout.bare' 'true'
    ++	git init --bare' 'nonbare' 'layout.bare' 'true'
     +
    - test_expect_success 'git-repo-info aborts if an invalid key is requested' '
    - 	test_when_finished "rm -rf expected err" &&
    - 	echo "error: key '\'foo\'' not found" >expected &&
    + test_expect_success 'git-repo-info fails if an invalid key is requested' '
    + 	echo "error: key '\'foo\'' not found" >expected_err &&
    + 	test_must_fail git repo info foo 2>actual_err &&
    +@@ t/t1900-repo.sh: test_expect_success 'only one value is returned if the same key is requested twi
    + 	test_cmp expect actual
    + '
    +
    ++test_expect_success 'output is returned correctly when two keys are requested' '
    ++	cat >expect <<-\EOF &&
    ++	layout.bare=false
    ++	references.format=files
    ++	EOF
    ++	git init --ref-format=files two-keys &&
    ++	git -C two-keys repo info layout.bare references.format
    ++'
    + test_done
4:  fa17719ebc ! 4:  f35704442a repo: add field layout.shallow
    @@ Metadata
     Author: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>

      ## Commit message ##
    -    repo: add field layout.shallow
    +    repo: add the field layout.shallow

         This commit is part of the series that introduces the new subcommand
         git-repo-info.
    @@ Commit message
         Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
         Helped-by: Junio C Hamano <gitster@pobox.com>
         Helped-by: Justin Tobler <jltobler@gmail.com>
    +    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
         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 ##
    -@@ Documentation/git-repo.adoc: Reference-related data:
    - `layout`::
    - Information about the how the current repository is represented:
    - * `bare`: `true` if this is a bare repository, otherwise `false`.
    -+* `shallow`: `true` if this is a shallow repository, otherwise `false`.
    +@@ Documentation/git-repo.adoc: values that they return:
    + `layout.bare`::
    + `true` if this is a bare repository, otherwise `false`.

    - SEE ALSO
    - --------
    ++`layout.shallow`::
    ++`true` if this is a shallow repository, otherwise `false`.
    ++
    + `references.format`::
    + The reference storage format. The valid values are:
    + +

      ## builtin/repo.c ##
     @@
    - #include "parse-options.h"
    + #include "quote.h"
      #include "refs.h"
      #include "strbuf.h"
     +#include "shallow.h"

    - typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
    -
    + static const char *const repo_usage[] = {
    + 	"git repo info [<key>...]",
     @@ builtin/repo.c: static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf)
      	return 0;
      }
    @@ builtin/repo.c: static int get_references_format(struct repository *repo, struct
      ## t/t1900-repo.sh ##
     @@ t/t1900-repo.sh: test_repo_info 'bare repository = false is retrieved correctly' '
      test_repo_info 'bare repository = true is retrieved correctly' '
    - 	git init --bare repo' 'layout.bare' 'true'
    + 	git init --bare' 'nonbare' 'layout.bare' 'true'

     +test_repo_info 'shallow repository = false is retrieved correctly' '
    -+	git init repo' 'layout.shallow' 'false'
    ++	git init' 'nonshallow' 'layout.shallow' 'false'
     +
     +test_repo_info 'shallow repository = true is retrieved correctly' '
     +	git init remote &&
    -+	cd remote &&
    -+	echo x >x &&
    -+	git add x &&
    -+	git commit -m x &&
    -+	cd .. &&
    -+	git clone --depth 1 "file://$PWD/remote" repo &&
    -+	rm -rf remote
    -+	' 'layout.shallow' 'true'
    ++	echo x >remote/x &&
    ++	git -C remote add x &&
    ++	git -C remote commit -m x &&
    ++	git clone --depth 1 "file://$PWD/remote"' 'shallow' 'layout.shallow' 'true'
     +
    - test_expect_success 'git-repo-info aborts if an invalid key is requested' '
    - 	test_when_finished "rm -rf expected err" &&
    - 	echo "error: key '\'foo\'' not found" >expected &&
    -@@ t/t1900-repo.sh: test_expect_success "only one value is returned if the same key is requested twi
    -         test_cmp expected_value actual_value
    + test_expect_success 'git-repo-info fails if an invalid key is requested' '
    + 	echo "error: key '\'foo\'' not found" >expected_err &&
    + 	test_must_fail git repo info foo 2>actual_err &&
    +@@ t/t1900-repo.sh: test_expect_success 'output is returned correctly when two keys are requested' '
    + 	git init --ref-format=files two-keys &&
    + 	git -C two-keys repo info layout.bare references.format
      '
    -
    -+test_expect_success 'output is returned correctly when two keys are requested' '
    -+	test_when_finished "rm -f expect" &&
    -+	printf "layout.bare=false\nlayout.shallow=false\n" >expect &&
    -+	git repo info layout.shallow layout.bare >actual &&
    -+	test_cmp expect actual
    -+'
     +
      test_done
5:  b72a61b73b ! 5:  8931b12eca repo: add the --format flag
    @@ Commit message
         Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
         Helped-by: Junio C Hamano <gitster@pobox.com>
         Helped-by: Justin Tobler <jltobler@gmail.com>
    +    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
         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: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN
      COMMANDS
      --------
     -`info [<key>...]`::
    -+`info [--format=<format>] [<key>...]`::
    ++`info [--format=<keyvalue|nul>] [<key>...]`::
      	Retrieve metadata-related information about the current repository. Only
      	the requested data will be returned based on their keys (see "INFO KEYS"
      	section below).
    + +
    + The returned data is lexicographically sorted by the keys.
     ++
     +The output format can be chosen through the flag `--format`. Two formats are
     +supported:
    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN

      INFO KEYS
      ---------
    +@@ Documentation/git-repo.adoc: The reference storage format. The valid values are:
    + +
    + include::ref-storage-format.adoc[]
    +
    ++
    ++Examples
    ++--------
    ++
    ++* Retrieves the reference format of the current repository:
    +++
    ++------------
    ++git repo info references.format
    ++------------
    +++
    ++
    ++* Retrieves whether the current repository is bare and whether it is shallow
    ++using the `nul` format:
    +++
    ++------------
    ++git repo info --format=nul layout.bare layout.shallow
    ++------------
    ++
    + SEE ALSO
    + --------
    + linkgit:git-rev-parse[1]

      ## builtin/repo.c ##
     @@
    + #include "shallow.h"
    +
    + static const char *const repo_usage[] = {
    +-	"git repo info [<key>...]",
    ++	"git repo info [--format=<keyvalue|nul>] [<key>...]",
    + 	NULL
    + };

      typedef int get_value_fn(struct repository *repo, struct strbuf *buf);

    @@ builtin/repo.c: static int qsort_strcmp(const void *va, const void *vb)
     +			struct repository *repo,
     +			enum output_format format)
      {
    + 	int ret = 0;
      	const char *last = "";
    + 	struct strbuf sb = STRBUF_INIT;
    +
     +	char kv_sep;
     +	char field_sep;
     +
    @@ builtin/repo.c: static int qsort_strcmp(const void *va, const void *vb)
     +		field_sep = '\0';
     +		break;
     +	}
    -
    ++
      	QSORT(argv, argc, qsort_strcmp);

    + 	for (int i = 0; i < argc; i++) {
    + 		get_value_fn *get_value;
    + 		const char *key = argv[i];
    +-		char *value;
    +
    + 		if (!strcmp(key, last))
    + 			continue;
     @@ builtin/repo.c: static int print_fields(int argc, const char **argv, struct repository *repo)
    - 		}
    + 		strbuf_reset(&sb);
    + 		get_value(repo, &sb);
    +
    +-		value = strbuf_detach(&sb, NULL);
    +-		quote_c_style(value, &sb, NULL, 0);
    +-		free(value);
    ++		if (format == FORMAT_KEYVALUE) {
    ++			char *value;
    ++			value = strbuf_detach(&sb, NULL);
    ++			quote_c_style(value, &sb, NULL, 0);
    ++			free(value);
    ++		}

    - 		get_value(repo, &value);
    --		printf("%s=%s\n", key, value.buf);
    -+		printf("%s%c%s%c", key, kv_sep, value.buf, field_sep);
    +-		printf("%s=%s\n", key, sb.buf);
    ++		printf("%s%c%s%c", key, kv_sep, sb.buf, field_sep);
      		last = key;
    - 		strbuf_release(&value);
      	}
    +
     @@ builtin/repo.c: static int print_fields(int argc, const char **argv, struct repository *repo)
    - 	return 0;
    + 	return ret;
      }

     -static int repo_info(int argc, const char **argv, const char *prefix UNUSED,
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv, struct repo
     -	return print_fields(argc - 1, argv + 1, repo);
     +	const char *format_str = "keyvalue";
     +	enum output_format format;
    -+	const char *const repo_info_usage[] = {
    -+		"git repo info [<key>...]",
    -+		NULL
    -+	};
     +	struct option options[] = {
     +		OPT_STRING(0, "format", &format_str, N_("format"),
     +			   N_("output format")),
     +		OPT_END()
     +	};
     +
    -+	argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);
    ++	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
     +
     +	if (!strcmp(format_str, "keyvalue"))
     +		format = FORMAT_KEYVALUE;
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv, struct repo

      ## t/t1900-repo.sh ##
     @@ t/t1900-repo.sh: test_repo_info () {
    - 	key=$3
    - 	expected_value=$4
    + 	key=$4
    + 	expected_value=$5

     -	test_expect_success "$label" '
    -+	test_expect_success "null-terminated: $label" '
    -+		test_when_finished "rm -rf repo" &&
    -+		eval "$init_command" &&
    -+		echo "$expected_value" | lf_to_nul >expected &&
    -+		git -C repo repo info --format=nul "$key" >output &&
    -+		tail -n 1 output >actual &&
    +-		eval "$init_command $repo_name" &&
    ++	test_expect_success "keyvalue: $label" '
    ++		eval "$init_command keyvalue-$repo_name" &&
    + 		echo "$key=$expected_value" >expected &&
    +-		git -C $repo_name repo info "$key" >actual &&
    ++		git -C keyvalue-$repo_name repo info "$key" >actual &&
     +		test_cmp expected actual
     +	'
     +
    -+	test_expect_success "key-value: $label" '
    - 		test_when_finished "rm -rf repo" &&
    - 		eval "$init_command" &&
    - 		echo "$expected_value" >expected &&
    --		git -C repo repo info "$key" >output &&
    -+		git -C repo repo info --format=keyvalue "$key" >output &&
    - 		cut -d "=" -f 2 <output >actual &&
    ++	test_expect_success "nul: $label" '
    ++		eval "$init_command nul-$repo_name" &&
    ++		printf "%s\n%s\0" "$key" "$expected_value" >expected &&
    ++		git -C nul-$repo_name repo info --format=nul "$key" >actual &&
      		test_cmp expected actual
      	'
    + }
    +@@ t/t1900-repo.sh: test_repo_info 'shallow repository = false is retrieved correctly' '
    + 	git init' 'nonshallow' 'layout.shallow' 'false'
    +
    + test_repo_info 'shallow repository = true is retrieved correctly' '
    ++	test_when_finished "rm -rf remote" &&
    + 	git init remote &&
    + 	echo x >remote/x &&
    + 	git -C remote add x &&
     @@ t/t1900-repo.sh: test_expect_success 'output is returned correctly when two keys are requested' '
    - 	test_cmp expect actual
    + 	git -C two-keys repo info layout.bare references.format
      '

     +test_expect_success 'git-repo-info aborts when requesting an invalid format' '

Lucas Seiki Oshiro (5):
  repo: declare the repo command
  repo: add the field references.format
  repo: add the field layout.bare
  repo: add the field layout.shallow
  repo: add the --format flag

 .gitignore                  |   1 +
 Documentation/git-repo.adoc |  81 +++++++++++++++++
 Documentation/meson.build   |   1 +
 Makefile                    |   1 +
 builtin.h                   |   1 +
 builtin/repo.c              | 173 ++++++++++++++++++++++++++++++++++++
 command-list.txt            |   1 +
 git.c                       |   1 +
 meson.build                 |   1 +
 t/meson.build               |   1 +
 t/t1900-repo.sh             |  97 ++++++++++++++++++++
 11 files changed, 359 insertions(+)
 create mode 100644 Documentation/git-repo.adoc
 create mode 100644 builtin/repo.c
 create mode 100755 t/t1900-repo.sh

-- 
2.39.5 (Apple Git-154)


  parent reply	other threads:[~2025-08-01 13:11 UTC|newest]

Thread overview: 226+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 15:21 [GSoC RFC PATCH 0/5] repo-info: add new command for retrieving repository info Lucas Seiki Oshiro
2025-06-10 15:21 ` [GSoC RFC PATCH 1/5] repo-info: declare the repo-info command Lucas Seiki Oshiro
2025-06-11  8:59   ` Karthik Nayak
2025-06-10 15:21 ` [GSoC RFC PATCH 2/5] repo-info: add the --format flag Lucas Seiki Oshiro
2025-06-11  9:30   ` Karthik Nayak
2025-06-12 17:56     ` Lucas Seiki Oshiro
2025-06-13  7:31       ` Karthik Nayak
2025-06-10 15:21 ` [GSoC RFC PATCH 3/5] repo-info: add the field references.format Lucas Seiki Oshiro
2025-06-11 12:59   ` Karthik Nayak
2025-06-12 15:01     ` Junio C Hamano
2025-06-10 15:21 ` [GSoC RFC PATCH 4/5] repo-info: add field layout.bare Lucas Seiki Oshiro
2025-06-11 13:13   ` Karthik Nayak
2025-06-12 19:39     ` Lucas Seiki Oshiro
2025-06-12 19:53       ` Junio C Hamano
2025-06-10 15:21 ` [GSoC RFC PATCH 5/5] repo-info: add field layout.shallow Lucas Seiki Oshiro
2025-06-10 16:39 ` [GSoC RFC PATCH 0/5] repo-info: add new command for retrieving repository info Kristoffer Haugsbakk
2025-06-10 16:40 ` Junio C Hamano
2025-06-12 20:25   ` Lucas Seiki Oshiro
2025-06-12 21:01     ` Junio C Hamano
2025-06-16 22:19       ` Lucas Seiki Oshiro
2025-06-16 22:40         ` Junio C Hamano
2025-06-19  1:44           ` Lucas Seiki Oshiro
2025-06-11 13:17 ` Karthik Nayak
2025-06-19 22:57 ` [GSoC RFC PATCH v2 0/7] " Lucas Seiki Oshiro
2025-06-19 22:57   ` [GSoC RFC PATCH v2 1/7] repo-info: declare the repo-info command Lucas Seiki Oshiro
2025-06-20  7:36     ` Karthik Nayak
2025-06-20 23:55       ` Junio C Hamano
2025-06-23  9:19         ` Karthik Nayak
2025-06-23 19:04       ` Lucas Seiki Oshiro
2025-06-20  7:56     ` Karthik Nayak
2025-06-24 14:03     ` Phillip Wood
2025-07-03 11:31     ` Patrick Steinhardt
2025-07-04 21:40       ` Lucas Seiki Oshiro
2025-07-07  6:01         ` Patrick Steinhardt
2025-07-09 20:05           ` Justin Tobler
2025-06-19 22:57   ` [GSoC RFC PATCH v2 2/7] repo-info: add the --format flag Lucas Seiki Oshiro
2025-06-20  8:06     ` Karthik Nayak
2025-06-20 21:31     ` Junio C Hamano
2025-07-03 11:31     ` Patrick Steinhardt
2025-06-19 22:57   ` [GSoC RFC PATCH v2 3/7] repo-info: add plaintext as an output format Lucas Seiki Oshiro
2025-06-20 21:37     ` Junio C Hamano
2025-07-03 11:32     ` Patrick Steinhardt
2025-06-19 22:57   ` [GSoC RFC PATCH v2 4/7] repo-info: add the --allow-empty flag Lucas Seiki Oshiro
2025-06-20  9:54     ` Karthik Nayak
2025-06-23  2:39       ` Lucas Seiki Oshiro
2025-06-20 21:39     ` Junio C Hamano
2025-06-23  9:26       ` Karthik Nayak
2025-06-23 20:28         ` Lucas Seiki Oshiro
2025-06-19 22:57   ` [GSoC RFC PATCH v2 5/7] repo-info: add the field references.format Lucas Seiki Oshiro
2025-06-20 22:26     ` Junio C Hamano
2025-06-24 14:03     ` Phillip Wood
2025-06-24 15:25       ` Junio C Hamano
2025-06-25  8:40         ` Phillip Wood
2025-07-03 11:32     ` Patrick Steinhardt
2025-07-04 21:11       ` Lucas Seiki Oshiro
2025-06-19 22:57   ` [GSoC RFC PATCH v2 6/7] repo-info: add field layout.bare Lucas Seiki Oshiro
2025-07-03 11:32     ` Patrick Steinhardt
2025-07-03 14:14       ` Lucas Seiki Oshiro
2025-07-04  8:32         ` Phillip Wood
2025-06-19 22:57   ` [GSoC RFC PATCH v2 7/7] repo-info: add field layout.shallow Lucas Seiki Oshiro
2025-06-23 13:42   ` [GSoC RFC PATCH v2 0/7] repo-info: add new command for retrieving repository info Phillip Wood
2025-06-23 18:49     ` Lucas Seiki Oshiro
2025-06-24 13:03       ` Phillip Wood
2025-06-24 13:43         ` Junio C Hamano
2025-07-01 22:18         ` Lucas Seiki Oshiro
2025-07-02  9:10           ` phillip.wood123
2025-07-06 23:19 ` [GSoC RFC PATCH v3 0/5] " Lucas Seiki Oshiro
2025-07-06 23:19   ` [GSoC RFC PATCH v3 1/5] repo-info: declare the repo-info command Lucas Seiki Oshiro
2025-07-06 23:19   ` [GSoC RFC PATCH v3 2/5] repo-info: add the --format flag Lucas Seiki Oshiro
2025-07-06 23:19   ` [GSoC RFC PATCH v3 3/5] repo-info: add the field references.format Lucas Seiki Oshiro
2025-07-06 23:19   ` [GSoC RFC PATCH v3 4/5] repo-info: add field layout.bare Lucas Seiki Oshiro
2025-07-06 23:19   ` [GSoC RFC PATCH v3 5/5] repo-info: add field layout.shallow Lucas Seiki Oshiro
2025-07-08 10:11   ` [GSoC RFC PATCH v3 0/5] repo-info: add new command for retrieving repository info Phillip Wood
2025-07-08 19:27     ` Lucas Seiki Oshiro
2025-07-10 13:15       ` Phillip Wood
2025-07-11 17:13   ` Lucas Seiki Oshiro
2025-07-11 17:37     ` Justin Tobler
2025-07-14 23:52 ` [GSoC RFC PATCH v4 0/4] repo: " Lucas Seiki Oshiro
2025-07-14 23:52   ` [GSoC RFC PATCH v4 1/4] repo: declare the repo command Lucas Seiki Oshiro
2025-07-15 11:52     ` Karthik Nayak
2025-07-15 11:59     ` Patrick Steinhardt
2025-07-15 18:38       ` Justin Tobler
2025-07-20 19:51       ` Lucas Seiki Oshiro
2025-07-15 18:19     ` Justin Tobler
2025-07-14 23:52   ` [GSoC RFC PATCH v4 2/4] repo: add the field references.format Lucas Seiki Oshiro
2025-07-15 11:59     ` Patrick Steinhardt
2025-07-18 19:13       ` Lucas Seiki Oshiro
2025-07-15 12:23     ` Karthik Nayak
2025-07-15 19:15     ` Justin Tobler
2025-07-16  5:38       ` Patrick Steinhardt
2025-07-16 14:04         ` Justin Tobler
2025-07-17 13:03           ` Patrick Steinhardt
2025-07-17 16:06             ` Justin Tobler
2025-07-18 20:26               ` Lucas Seiki Oshiro
2025-07-21 14:41                 ` Justin Tobler
2025-07-14 23:52   ` [GSoC RFC PATCH v4 3/4] repo: add field layout.bare Lucas Seiki Oshiro
2025-07-14 23:52   ` [GSoC RFC PATCH v4 4/4] repo: add field layout.shallow Lucas Seiki Oshiro
2025-07-15 10:34   ` [GSoC RFC PATCH v4 0/4] repo: add new command for retrieving repository info Oswald Buddenhagen
2025-07-15 11:58     ` Patrick Steinhardt
2025-07-15 12:20       ` Oswald Buddenhagen
2025-07-15 19:36       ` Justin Tobler
2025-07-15 16:49     ` Junio C Hamano
2025-07-17 10:25       ` Oswald Buddenhagen
2025-07-17 10:42         ` Patrick Steinhardt
2025-07-16 20:20   ` Junio C Hamano
2025-07-16 20:33     ` Junio C Hamano
2025-07-21 22:05     ` Lucas Seiki Oshiro
2025-07-22  0:28 ` [GSoC PATCH v5 0/5] " Lucas Seiki Oshiro
2025-07-22  0:28   ` [GSoC PATCH v5 1/5] repo: declare the repo command Lucas Seiki Oshiro
2025-07-22  9:03     ` Karthik Nayak
2025-07-22 15:21       ` Junio C Hamano
2025-07-23 16:28         ` Lucas Seiki Oshiro
2025-07-23 17:48           ` Junio C Hamano
2025-07-24  6:22         ` Patrick Steinhardt
2025-07-24 16:06           ` Junio C Hamano
2025-07-25  5:10             ` Patrick Steinhardt
2025-07-26 21:54           ` Lucas Seiki Oshiro
2025-07-28 17:56             ` Junio C Hamano
2025-07-23 15:49       ` Lucas Seiki Oshiro
2025-07-23 20:03     ` Jean-Noël AVILA
2025-07-22  0:28   ` [GSoC PATCH v5 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-07-22  9:16     ` Karthik Nayak
2025-07-22 19:25     ` Justin Tobler
2025-07-23 14:53       ` Phillip Wood
2025-07-23 17:44         ` Lucas Seiki Oshiro
2025-07-23 18:26       ` Lucas Seiki Oshiro
2025-07-24  6:22     ` Patrick Steinhardt
2025-07-22  0:28   ` [GSoC PATCH v5 3/5] repo: add field layout.bare Lucas Seiki Oshiro
2025-07-22  0:28   ` [GSoC PATCH v5 4/5] repo: add field layout.shallow Lucas Seiki Oshiro
2025-07-22  0:28   ` [GSoC PATCH v5 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-07-22  9:26     ` Karthik Nayak
2025-07-24  6:22     ` Patrick Steinhardt
2025-07-27 17:51 ` [GSoC PATCH v5 0/5] repo: add new command for retrieving repository info Lucas Seiki Oshiro
2025-07-27 17:51   ` [GSoC PATCH v5 1/5] repo: declare the repo command Lucas Seiki Oshiro
2025-07-27 20:20     ` Eric Sunshine
2025-07-27 17:51   ` [GSoC PATCH v5 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-07-27 21:16     ` Eric Sunshine
2025-07-31 19:39       ` Lucas Seiki Oshiro
2025-07-29  9:35     ` Patrick Steinhardt
2025-07-31 19:49       ` Lucas Seiki Oshiro
2025-07-27 17:51   ` [GSoC PATCH v5 3/5] repo: add field layout.bare Lucas Seiki Oshiro
2025-07-27 17:51   ` [GSoC PATCH v5 4/5] repo: add field layout.shallow Lucas Seiki Oshiro
2025-07-27 21:45     ` Eric Sunshine
2025-07-27 17:51   ` [GSoC PATCH v5 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-07-27 22:02     ` Eric Sunshine
2025-07-29  0:15       ` Ben Knoble
2025-07-29  0:27         ` Eric Sunshine
2025-07-29  0:38           ` Ben Knoble
2025-07-29  0:39           ` Eric Sunshine
2025-07-31 23:01       ` Lucas Seiki Oshiro
2025-07-31 23:15     ` Lucas Seiki Oshiro
2025-07-27 20:11   ` [GSoC PATCH v5 0/5] repo: add new command for retrieving repository info Eric Sunshine
2025-07-29  9:35     ` Patrick Steinhardt
2025-07-30 15:26     ` Lucas Seiki Oshiro
2025-08-01 13:11 ` Lucas Seiki Oshiro [this message]
2025-08-01 13:11   ` [GSoC PATCH v7 1/5] repo: declare the repo command Lucas Seiki Oshiro
2025-08-01 13:11   ` [GSoC PATCH v7 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-08-01 20:59     ` Eric Sunshine
2025-08-03 21:47       ` Lucas Seiki Oshiro
2025-08-01 13:11   ` [GSoC PATCH v7 3/5] repo: add the field layout.bare Lucas Seiki Oshiro
2025-08-01 21:21     ` Eric Sunshine
2025-08-03 22:54       ` Lucas Seiki Oshiro
2025-08-03 23:06         ` Eric Sunshine
2025-08-05 12:50     ` Patrick Steinhardt
2025-08-01 13:11   ` [GSoC PATCH v7 4/5] repo: add the field layout.shallow Lucas Seiki Oshiro
2025-08-05 12:50     ` Patrick Steinhardt
2025-08-01 13:11   ` [GSoC PATCH v7 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-08-01 19:25     ` Junio C Hamano
2025-08-01 20:27     ` Jean-Noël AVILA
2025-08-01 21:50     ` Eric Sunshine
2025-08-05 12:50     ` Patrick Steinhardt
2025-08-05 12:50   ` [GSoC PATCH v7 0/5] repo: add new command for retrieving repository info Patrick Steinhardt
2025-08-06 19:55 ` [GSoC PATCH v8 " Lucas Seiki Oshiro
2025-08-06 19:55   ` [GSoC PATCH v8 1/5] repo: declare the repo command Lucas Seiki Oshiro
2025-08-06 19:55   ` [GSoC PATCH v8 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-08-07  7:43     ` Karthik Nayak
2025-08-06 19:55   ` [GSoC PATCH v8 3/5] repo: add the field layout.bare Lucas Seiki Oshiro
2025-08-07  5:20     ` Patrick Steinhardt
2025-08-06 19:55   ` [GSoC PATCH v8 4/5] repo: add the field layout.shallow Lucas Seiki Oshiro
2025-08-06 19:55   ` [GSoC PATCH v8 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-08-07  5:20     ` Patrick Steinhardt
2025-08-07 15:44       ` Junio C Hamano
2025-08-06 22:38   ` [GSoC PATCH v8 0/5] repo: add new command for retrieving repository info Junio C Hamano
2025-08-07  7:48   ` Karthik Nayak
2025-08-07 15:02 ` [GSoC PATCH v9 " Lucas Seiki Oshiro
2025-08-07 15:02   ` [GSoC PATCH v9 1/5] repo: declare the repo command Lucas Seiki Oshiro
2025-08-07 15:02   ` [GSoC PATCH v9 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-08-11  5:12     ` Eric Sunshine
2025-08-11 14:41     ` Phillip Wood
2025-08-11 15:44       ` Junio C Hamano
2025-08-13 21:18       ` Lucas Seiki Oshiro
2025-08-13 21:46         ` Eric Sunshine
2025-08-13 22:24           ` Lucas Seiki Oshiro
2025-08-14 13:58           ` Phillip Wood
2025-08-07 15:02   ` [GSoC PATCH v9 3/5] repo: add the field layout.bare Lucas Seiki Oshiro
2025-08-11  5:21     ` Eric Sunshine
2025-08-14 18:22       ` Lucas Seiki Oshiro
2025-08-14 18:32         ` Eric Sunshine
2025-08-14 18:51           ` Junio C Hamano
2025-08-14 22:05             ` Eric Sunshine
2025-08-15  1:20               ` Junio C Hamano
2025-08-14 22:18             ` Lucas Seiki Oshiro
2025-08-14 23:41               ` Eric Sunshine
2025-08-07 15:02   ` [GSoC PATCH v9 4/5] repo: add the field layout.shallow Lucas Seiki Oshiro
2025-08-07 15:02   ` [GSoC PATCH v9 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-08-11  5:44     ` Eric Sunshine
2025-08-08  5:45   ` [GSoC PATCH v9 0/5] repo: add new command for retrieving repository info Patrick Steinhardt
2025-08-08 15:02     ` Junio C Hamano
2025-08-08  9:20   ` Karthik Nayak
2025-08-15 13:55 ` [GSoC PATCH v10 0/5] repo: declare the repo command Lucas Seiki Oshiro
2025-08-15 13:55   ` [GSoC PATCH v10 1/5] " Lucas Seiki Oshiro
2025-08-15 13:55   ` [GSoC PATCH v10 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-08-15 18:40     ` Junio C Hamano
2025-08-15 19:12       ` Lucas Seiki Oshiro
2025-08-15 13:55   ` [GSoC PATCH v10 3/5] repo: add the field layout.bare Lucas Seiki Oshiro
2025-08-15 13:55   ` [GSoC PATCH v10 4/5] repo: add the field layout.shallow Lucas Seiki Oshiro
2025-08-15 19:36     ` Junio C Hamano
2025-08-15 13:55   ` [GSoC PATCH v10 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-08-15 19:23     ` Junio C Hamano
2025-08-16 22:45 ` [GSoC PATCH v11 0/5] repo: declare the repo command Lucas Seiki Oshiro
2025-08-16 22:45   ` [GSoC PATCH v11 1/5] " Lucas Seiki Oshiro
2025-08-16 22:46   ` [GSoC PATCH v11 2/5] repo: add the field references.format Lucas Seiki Oshiro
2025-08-16 22:46   ` [GSoC PATCH v11 3/5] repo: add the field layout.bare Lucas Seiki Oshiro
2025-08-16 22:46   ` [GSoC PATCH v11 4/5] repo: add the field layout.shallow Lucas Seiki Oshiro
2025-08-16 22:46   ` [GSoC PATCH v11 5/5] repo: add the --format flag Lucas Seiki Oshiro
2025-08-17 16:21   ` [GSoC PATCH v11 0/5] repo: declare the repo command 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=20250801131111.8115-1-lucasseikioshiro@gmail.com \
    --to=lucasseikioshiro@gmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=jn.avila@free.fr \
    --cc=karthik.188@gmail.com \
    --cc=oswald.buddenhagen@gmx.de \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=ps@pks.im \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).