[PATCH v3 4/5] t1900: cover repo info path keys and path-format
- From
- Eslam reda ragheb via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Feb 23, 2026, 19:43 UTC
- Message-ID
- <6ea263fee9fcf670ca2f9f26fa86a76ce0701c9e.1771875812.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2208.v3.git.git.1771875812.gitgitgadget@gmail.com>
From: Eslam reda ragheb <eslam.reda.div@gmail.com>
Extend t1900 to validate category-key expansion, path.* key behavior, and --path-format handling for git repo info.
The tests compare repo info output to equivalent rev-parse values.
This ensures behavior remains aligned with existing plumbing semantics.
Also keep mixed key/category ordering coverage so callers can rely on deterministic output order when combining explicit keys with category requests.
Signed-off-by: Eslam reda ragheb <eslam.reda.div@gmail.com> --- t/t1900-repo.sh | 196 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+)
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh index 51d55f11a5..dcacf84cc3 100755 --- a/t/t1900-repo.sh +++ b/t/t1900-repo.sh @@ -10,9 +10,40 @@ REPO_INFO_KEYS=' layout.bare layout.shallow object.format + path.common-dir + path.config-file + path.git-dir + path.git-prefix + path.grafts-file + path.hooks-directory + path.index-file + path.logs-directory + path.objects-directory + path.packed-refs-file + path.refs-directory + path.shallow-file + path.superproject-working-tree + path.toplevel references.format ' +REPO_INFO_PATH_KEYS=' + path.common-dir + path.config-file + path.git-dir + path.git-prefix + path.grafts-file + path.hooks-directory + path.index-file + path.logs-directory + path.objects-directory + path.packed-refs-file + path.refs-directory + path.shallow-file + path.superproject-working-tree + path.toplevel +' + # Test whether a key-value pair is correctly returned # # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value> @@ -89,6 +120,171 @@ test_expect_success 'values returned in order requested' ' test_cmp expect actual ' +test_expect_success 'category key returns all matching keys' ' + cat >expect <<-\EOF && + layout.bare=false + layout.shallow=false + EOF + git init category-layout && + git -C category-layout repo info layout >actual && + test_cmp expect actual +' + +test_expect_success 'mixed key/category requests preserve request order' ' + cat >expect <<-EOF && + object.format=$(test_oid algo) + layout.bare=false + layout.shallow=false + EOF + git init mixed-order && + git -C mixed-order repo info object.format layout >actual && + test_cmp expect actual +' + +test_expect_success 'path.git-dir matches rev-parse --absolute-git-dir' ' + git init path-git-dir && + expected_value=$(git -C path-git-dir rev-parse --absolute-git-dir) && + echo "path.git-dir=$expected_value" >expect && + git -C path-git-dir repo info path.git-dir >actual && + test_cmp expect actual +' + +test_expect_success 'path.common-dir matches rev-parse --git-common-dir' ' + git init path-common-dir && + expected_value=$(git -C path-common-dir rev-parse --path-format=absolute --git-common-dir) && + echo "path.common-dir=$expected_value" >expect && + git -C path-common-dir repo info path.common-dir >actual && + test_cmp expect actual +' + +test_expect_success 'path.toplevel matches rev-parse --show-toplevel' ' + git init path-toplevel && + expected_value=$(git -C path-toplevel rev-parse --show-toplevel) && + echo "path.toplevel=$expected_value" >expect && + git -C path-toplevel repo info path.toplevel >actual && + test_cmp expect actual +' + +test_expect_success 'path.toplevel is empty in bare repository' ' + git init --bare bare-path-toplevel && + echo "path.toplevel=" >expect && + git -C bare-path-toplevel repo info path.toplevel >actual && + test_cmp expect actual +' + +test_expect_success 'path.git-prefix matches rev-parse --show-prefix' ' + git init path-prefix && + mkdir -p path-prefix/a/b && + expected_value=$(git -C path-prefix/a/b rev-parse --show-prefix) && + echo "path.git-prefix=$expected_value" >expect && + git -C path-prefix/a/b repo info path.git-prefix >actual && + test_cmp expect actual +' + +test_expect_success 'git-path style keys match rev-parse --git-path' ' + git init path-git-path && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path info/grafts) && + echo "path.grafts-file=$expected_value" >expect && + git -C path-git-path repo info path.grafts-file >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path index) && + echo "path.index-file=$expected_value" >expect && + git -C path-git-path repo info path.index-file >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path objects) && + echo "path.objects-directory=$expected_value" >expect && + git -C path-git-path repo info path.objects-directory >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path hooks) && + echo "path.hooks-directory=$expected_value" >expect && + git -C path-git-path repo info path.hooks-directory >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path config) && + echo "path.config-file=$expected_value" >expect && + git -C path-git-path repo info path.config-file >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path logs) && + echo "path.logs-directory=$expected_value" >expect && + git -C path-git-path repo info path.logs-directory >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path packed-refs) && + echo "path.packed-refs-file=$expected_value" >expect && + git -C path-git-path repo info path.packed-refs-file >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path refs) && + echo "path.refs-directory=$expected_value" >expect && + git -C path-git-path repo info path.refs-directory >actual && + test_cmp expect actual && + + expected_value=$(git -C path-git-path rev-parse --path-format=absolute --git-path shallow) && + echo "path.shallow-file=$expected_value" >expect && + git -C path-git-path repo info path.shallow-file >actual && + test_cmp expect actual +' + +test_expect_success 'path.superproject-working-tree is empty when not a submodule' ' + git init path-superproject && + echo "path.superproject-working-tree=" >expect && + git -C path-superproject repo info path.superproject-working-tree >actual && + test_cmp expect actual +' + +test_expect_success 'path.superproject-working-tree matches rev-parse in submodule' ' + git init path-superproject-origin && + echo x >path-superproject-origin/x && + git -C path-superproject-origin add x && + git -C path-superproject-origin commit -m x && + + git init path-superproject-parent && + git -C path-superproject-parent -c protocol.file.allow=always submodule add ../path-superproject-origin sm && + + expected_value=$(git -C path-superproject-parent/sm rev-parse --show-superproject-working-tree) && + echo "path.superproject-working-tree=$expected_value" >expect && + git -C path-superproject-parent/sm repo info path.superproject-working-tree >actual && + test_cmp expect actual +' + +test_expect_success 'path category returns all path keys' ' + git init path-category && + >expect && + for key in $REPO_INFO_PATH_KEYS + do + git -C path-category repo info "$key" >>expect || return 1 + done && + git -C path-category repo info path >actual && + test_cmp expect actual +' + +test_expect_success 'path-format=relative matches rev-parse for git-dir' ' + git init path-format-relative && + expected_value=$(git -C path-format-relative rev-parse --path-format=relative --git-dir) && + echo "path.git-dir=$expected_value" >expect && + git -C path-format-relative repo info --path-format=relative path.git-dir >actual && + test_cmp expect actual +' + +test_expect_success 'git repo info uses the last requested path format' ' + git init path-format-last && + expected_value=$(git -C path-format-last rev-parse --path-format=relative --git-dir) && + echo "path.git-dir=$expected_value" >expect && + git -C path-format-last repo info --path-format=absolute --path-format=relative path.git-dir >actual && + test_cmp expect actual +' + +test_expect_success 'git-repo-info aborts when requesting an invalid path format' ' + echo "fatal: invalid path format ${SQ}foo${SQ}" >expect && + test_must_fail git repo info --path-format=foo path.git-dir 2>actual && + test_cmp expect actual +' + test_expect_success 'git-repo-info fails if an invalid key is requested' ' echo "error: key ${SQ}foo${SQ} not found" >expect && test_must_fail git repo info foo 2>actual &&
-- gitgitgadget