diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-02-27 15:11:49 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-02-27 15:11:49 -0800 |
| commit | 341be27dfef8aba66f10be58aec1395075081e85 (patch) | |
| tree | 960e953bd1ab6699b0262d7517d27d0edee3c205 /t | |
| parent | 7b2bccb0d58d4f24705bf985de1f4612e4cf06e5 (diff) | |
| parent | 173c43be54f0039a9f6e13afaad3c953bb6b06dc (diff) | |
| download | git-341be27dfef8aba66f10be58aec1395075081e85.tar.xz | |
Merge branch 'lo/repo-info-keys'
"git repo info" learns "--keys" action to list known keys.
* lo/repo-info-keys:
repo: add new flag --keys to git-repo-info
repo: rename the output format "keyvalue" to "lines"
Diffstat (limited to 't')
| -rwxr-xr-x | t/t1900-repo.sh | 44 | ||||
| -rwxr-xr-x | t/t1901-repo-structure.sh | 4 |
2 files changed, 33 insertions, 15 deletions
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh index 51d55f11a5..a9eb07abe8 100755 --- a/t/t1900-repo.sh +++ b/t/t1900-repo.sh @@ -4,15 +4,6 @@ test_description='test git repo-info' . ./test-lib.sh -# git-repo-info keys. It must contain the same keys listed in the const -# repo_info_fields, in lexicographical order. -REPO_INFO_KEYS=' - layout.bare - layout.shallow - object.format - references.format -' - # Test whether a key-value pair is correctly returned # # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value> @@ -34,7 +25,7 @@ test_repo_info () { eval "$init_command $repo_name" ' - test_expect_success "keyvalue: $label" ' + test_expect_success "lines: $label" ' echo "$key=$expected_value" > expect && git -C "$repo_name" repo info "$key" >actual && test_cmp expect actual @@ -115,12 +106,12 @@ test_expect_success '-z uses nul-terminated format' ' test_expect_success 'git repo info uses the last requested format' ' echo "layout.bare=false" >expected && - git repo info --format=nul -z --format=keyvalue layout.bare >actual && + git repo info --format=nul -z --format=lines layout.bare >actual && test_cmp expected actual ' -test_expect_success 'git repo info --all returns all key-value pairs' ' - git repo info $REPO_INFO_KEYS >expect && +test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' ' + git repo info $(git repo info --keys) >expect && git repo info --all >actual && test_cmp expect actual ' @@ -131,4 +122,31 @@ test_expect_success 'git repo info --all <key> aborts' ' test_cmp expect actual ' +test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' ' + git repo info --keys --format=lines >lines && + lf_to_nul <lines >expect && + git repo info --keys --format=nul >actual && + test_cmp expect actual +' + +test_expect_success 'git repo info --keys aborts when using --format other than lines or nul' ' + echo "fatal: --keys can only be used with --format=lines or --format=nul" >expect && + test_must_fail git repo info --keys --format=table 2>actual && + test_cmp expect actual +' + +test_expect_success 'git repo info --keys aborts when requesting keys' ' + echo "fatal: --keys cannot be used with a <key> or --all" >expect && + test_must_fail git repo info --keys --all 2>actual_all && + test_must_fail git repo info --keys some.key 2>actual_key && + test_cmp expect actual_all && + test_cmp expect actual_key +' + +test_expect_success 'git repo info --keys uses lines as its default output format' ' + git repo info --keys --format=lines >expect && + git repo info --keys >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh index 17ff164b05..a6f2591d9a 100755 --- a/t/t1901-repo-structure.sh +++ b/t/t1901-repo-structure.sh @@ -113,7 +113,7 @@ test_expect_success SHA1 'repository with references and objects' ' ) ' -test_expect_success SHA1 'keyvalue and nul format' ' +test_expect_success SHA1 'lines and nul format' ' test_when_finished "rm -rf repo" && git init repo && ( @@ -140,7 +140,7 @@ test_expect_success SHA1 'keyvalue and nul format' ' objects.tags.disk_size=$(object_type_disk_usage tag) EOF - git repo structure --format=keyvalue >out 2>err && + git repo structure --format=lines >out 2>err && test_cmp expect out && test_line_count = 0 err && |
