mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
This commit is part of the series that introduces the new subcommand git-repo-info. The flag --is-bare-repository from git-rev-parse is used for retrieving whether the current repository is bare. This way, it is used for querying repository metadata, fitting in the purpose of git-repo-info. Then, add a new field layout.bare to the git-repo-info subcommand containing that information. 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
71 lines
2.0 KiB
Bash
Executable File
71 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='test git repo-info'
|
|
|
|
. ./test-lib.sh
|
|
|
|
# Test whether a key-value pair is correctly returned
|
|
#
|
|
# Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
|
|
#
|
|
# Arguments:
|
|
# label: the label of the test
|
|
# init_command: a command which creates a repository
|
|
# repo_name: the name of the repository that will be created in init_command
|
|
# 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
|
|
repo_name=$3
|
|
key=$4
|
|
expected_value=$5
|
|
|
|
test_expect_success "setup: $label" '
|
|
eval "$init_command $repo_name"
|
|
'
|
|
|
|
test_expect_success "$label" '
|
|
echo "$key=$expected_value" >expect &&
|
|
git -C $repo_name repo info "$key" >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
}
|
|
|
|
test_repo_info 'ref format files is retrieved correctly' \
|
|
'git init --ref-format=files' 'format-files' 'references.format' 'files'
|
|
|
|
test_repo_info 'ref format reftable is retrieved correctly' \
|
|
'git init --ref-format=reftable' 'format-reftable' 'references.format' 'reftable'
|
|
|
|
test_repo_info 'bare repository = false is retrieved correctly' \
|
|
'git init' 'nonbare' 'layout.bare' 'false'
|
|
|
|
test_repo_info 'bare repository = true is retrieved correctly' \
|
|
'git init --bare' 'bare' 'layout.bare' 'true'
|
|
|
|
test_expect_success 'values returned in order requested' '
|
|
cat >expect <<-\EOF &&
|
|
layout.bare=false
|
|
references.format=files
|
|
layout.bare=false
|
|
EOF
|
|
git init --ref-format=files ordered &&
|
|
git -C ordered repo info layout.bare references.format layout.bare >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 &&
|
|
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)" >expect &&
|
|
test_must_fail git repo info foo references.format bar >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|