Subject: [GSoC PATCH v11 0/5] repo: declare the repo command

From: Lucas Seiki Oshiro <[email-masked]>
Date: Sat, 16 Aug 2025 19:45:58 -0300

Hi!

This v11 addresses the minor issues pointed by Junio in v10. They are mostly
spelling changes:

- using "expect" and "actual" in all test_cmp calls, even when we're capturing
  stderr

- indent list items in the documentation

- use a nested description list when describing the possible values of --format

- spelling: "NUL characters" instead of "null characters"

- initialize the repository in `test_repo_info` outside the test cases,
  creating a single repository for both keyvalue and nul formats

Here's the rangediff versus v10:

1:  6767028da3 = 1:  6767028da3 repo: declare the repo command
2:  c44e2d1619 ! 2:  1a3fa8e12f repo: add the field references.format
    @@ Documentation/git-repo.adoc: COMMANDS
     +values that they return:
     +
     +`references.format`::
    -+The reference storage format. The valid values are:
    ++	The reference storage format. The valid values are:
     ++
     +include::ref-storage-format.adoc[]

    @@ t/t1900-repo.sh (new)
     +	key=$4
     +	expected_value=$5
     +
    ++	test_expect_success "setup: $label" '
    ++		eval "$init_command $repo_name"
    ++	'
    ++
     +	test_expect_success "$label" '
    -+		eval "$init_command $repo_name" &&
    -+		echo "$key=$expected_value" >expected &&
    ++		echo "$key=$expected_value" >expect &&
     +		git -C $repo_name repo info "$key" >actual &&
    -+		test_cmp expected actual
    ++		test_cmp expect actual
     +	'
     +}
     +
    @@ t/t1900-repo.sh (new)
     +	'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 ${SQ}foo${SQ} not found" >expected_err &&
    -+	test_must_fail git repo info foo 2>actual_err &&
    -+	test_cmp expected_err actual_err
    ++	echo "error: key ${SQ}foo${SQ} not found" >expect &&
    ++	test_must_fail git repo info foo 2>actual &&
    ++	test_cmp expect actual
     +'
     +
     +test_expect_success 'git-repo-info outputs data even if there is an invalid field' '
    -+	echo "references.format=$(test_detect_ref_format)" >expected &&
    ++	echo "references.format=$(test_detect_ref_format)" >expect &&
     +	test_must_fail git repo info foo references.format bar >actual &&
    -+	test_cmp expected actual
    ++	test_cmp expect actual
     +'
     +
     +test_done
3:  e3009a85e1 ! 3:  a3b05def63 repo: add the field layout.bare
    @@ Documentation/git-repo.adoc: In order to obtain a set of values from `git repo i
      values that they return:

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

      ## builtin/repo.c ##
    @@ t/t1900-repo.sh: test_repo_info 'ref format files is retrieved correctly' \
     +'
     +
      test_expect_success 'git-repo-info fails if an invalid key is requested' '
    - 	echo "error: key ${SQ}foo${SQ} not found" >expected_err &&
    - 	test_must_fail git repo info foo 2>actual_err &&
    + 	echo "error: key ${SQ}foo${SQ} not found" >expect &&
    + 	test_must_fail git repo info foo 2>actual &&
4:  3837899c32 ! 4:  034dd414e5 repo: add the field layout.shallow
    @@ Commit message
      ## Documentation/git-repo.adoc ##
     @@ Documentation/git-repo.adoc: values that they return:
      `layout.bare`::
    - `true` if this is a bare repository, otherwise `false`.
    + 	`true` if this is a bare repository, otherwise `false`.

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

      ## builtin/repo.c ##
5:  19fdfce646 ! 5:  442a3b7afa repo: add the --format flag
    @@ Commit message
         - keyvalue, where the retrieved data is printed one per line, using =
           for delimiting the key and the value. This is the default format,
           targeted for end users.
    -    - nul, where the retrieved data is separated by null characters, using
    +    - nul, where the retrieved data is separated by NUL characters, using
           the newline character for delimiting the key and the value. This
           format is targeted for being read by machines.

    @@ Documentation/git-repo.adoc: COMMANDS
     +The output format can be chosen through the flag `--format`. Two formats are
     +supported:
     ++
    -+* `keyvalue`: output key-value pairs one per line using the `=` character as
    -+the delimiter between the key and the value. Values containing "unusual"
    -+characters are quoted as explained for the configuration variable
    -+`core.quotePath` (see linkgit:git-config[1]). This is the default.
    ++`keyvalue`:::
    ++	output key-value pairs one per line using the `=` character as
    ++	the delimiter between the key and the value. Values containing "unusual"
    ++	characters are quoted as explained for the configuration variable
    ++	`core.quotePath` (see linkgit:git-config[1]). This is the default.
     +
    -+* `nul`: similar to `keyvalue`, but using a newline character as the delimiter
    -+between the key and the value and using a null character after each value.
    -+This format is better suited for being parsed by another applications than
    -+`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.
    ++`nul`:::
    ++	similar to `keyvalue`, but using a newline character as the delimiter
    ++	between the key and the value and using a NUL character after each value.
    ++	This format is better suited for being parsed by another applications than
    ++	`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.

      INFO KEYS
      ---------
    @@ Documentation/git-repo.adoc: COMMANDS
      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:
    -@@ Documentation/git-repo.adoc: The reference storage format. The valid values are:
    +@@ Documentation/git-repo.adoc: values that they return:
      +
      include::ref-storage-format.adoc[]

    @@ 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=$4
    - 	expected_value=$5
    + 		eval "$init_command $repo_name"
    + 	'

     -	test_expect_success "$label" '
    --		eval "$init_command $repo_name" &&
    --		echo "$key=$expected_value" >expected &&
    +-		echo "$key=$expected_value" >expect &&
     -		git -C $repo_name repo info "$key" >actual &&
    -+	repo_name_keyvalue="$repo_name"-keyvalue
    -+	repo_name_nul="$repo_name"-nul
    -+
     +	test_expect_success "keyvalue: $label" '
    -+		eval "$init_command $repo_name_keyvalue" &&
    -+		echo "$key=$expected_value" > expected &&
    -+		git -C "$repo_name_keyvalue" repo info "$key" >actual &&
    - 		test_cmp expected actual
    ++		echo "$key=$expected_value" > expect &&
    ++		git -C "$repo_name" repo info "$key" >actual &&
    + 		test_cmp expect actual
      	'
     +
     +	test_expect_success "nul: $label" '
    -+		eval "$init_command $repo_name_nul" &&
    -+		printf "%s\n%s\0" "$key" "$expected_value" >expected &&
    -+		git -C "$repo_name_nul" repo info --format=nul "$key" >actual &&
    -+		test_cmp_bin expected actual
    ++		printf "%s\n%s\0" "$key" "$expected_value" >expect &&
    ++		git -C "$repo_name" repo info --format=nul "$key" >actual &&
    ++		test_cmp_bin expect actual
     +	'
      }

      test_repo_info 'ref format files is retrieved correctly' \
     @@ t/t1900-repo.sh: test_expect_success 'git-repo-info outputs data even if there is an invalid fiel
    - 	test_cmp expected actual
    + 	test_cmp expect actual
      '

     +test_expect_success 'git-repo-info aborts when requesting an invalid format' '
    -+	echo "fatal: invalid format ${SQ}foo${SQ}" >expected &&
    -+	test_must_fail git repo info --format=foo 2>err &&
    -+	test_cmp expected err
    ++	echo "fatal: invalid format ${SQ}foo${SQ}" >expect &&
    ++	test_must_fail git repo info --format=foo 2>actual &&
    ++	test_cmp expect actual
     +'
     +
      test_done

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 |  84 ++++++++++++++++++++
 Documentation/meson.build   |   1 +
 Makefile                    |   1 +
 builtin.h                   |   1 +
 builtin/repo.c              | 150 ++++++++++++++++++++++++++++++++++++
 command-list.txt            |   1 +
 git.c                       |   1 +
 meson.build                 |   1 +
 t/meson.build               |   1 +
 t/t1900-repo.sh             |  95 +++++++++++++++++++++++
 11 files changed, 337 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)