Re: [GSoC PATCH v9 5/5] repo: add the --format flag
From: Eric Sunshine <hidden>
Date: 2025-08-11 05:44:36
On Thu, Aug 7, 2025 at 11:04 AM Lucas Seiki Oshiro [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Add the --format flag to git-repo-info. By using this flag, the users can choose the format for obtaining the data they requested. [...] Signed-off-by: Lucas Seiki Oshiro <redacted> ---diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh@@ -21,12 +21,22 @@ test_repo_info () { - test_expect_success "$label" ' - eval "$init_command $repo_name" && - echo "$key=$expected_value" >expected && - 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 &&
Style nit: drop space following redirection operator[1]. Not worth a reroll.
quoted hunk ↗ jump to hunk
+ git -C "$repo_name_keyvalue" repo info "$key" >actual && test_cmp expected 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 + ' }@@ -44,12 +54,15 @@ test_repo_info 'bare repository = true 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 &&
Nit: Here you used ${SQ} as suggested by Karthik[2]...
quoted hunk ↗ jump to hunk
@@ -80,4 +93,10 @@ test_expect_success 'output is returned correctly when two keys are requested' ' +test_expect_success 'git-repo-info aborts when requesting an invalid format' ' + echo "fatal: invalid format '\'foo\''" >expected &&
...but here you did not.
+ test_must_fail git repo info --format=foo 2>err && + test_cmp expected err +'
[1]: https://lore.kernel.org/git/aJQ3sVf4MsgnCaMz@pks.im/ (local) [2]: https://lore.kernel.org/git/CAOLa=ZSX0hFt7PRdXssz2xGG17bmDchS=EheBSmQj9xr+r_baA@mail.gmail.com/ (local)