2021-12-03 14:34:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test the `scalar` command'
|
|
|
|
|
|
|
|
TEST_DIRECTORY=$PWD/../../../t
|
|
|
|
export TEST_DIRECTORY
|
|
|
|
|
|
|
|
# Make it work with --no-bin-wrappers
|
|
|
|
PATH=$PWD/..:$PATH
|
|
|
|
|
|
|
|
. ../../../t/test-lib.sh
|
|
|
|
|
2021-12-03 14:34:23 +01:00
|
|
|
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab ../cron.txt,launchctl:true,schtasks:true"
|
|
|
|
export GIT_TEST_MAINT_SCHEDULER
|
|
|
|
|
2021-12-03 14:34:18 +01:00
|
|
|
test_expect_success 'scalar shows a usage' '
|
|
|
|
test_expect_code 129 scalar -h
|
|
|
|
'
|
|
|
|
|
2021-12-03 14:34:21 +01:00
|
|
|
test_expect_success 'scalar unregister' '
|
|
|
|
git init vanish/src &&
|
|
|
|
scalar register vanish/src &&
|
|
|
|
git config --get --global --fixed-value \
|
|
|
|
maintenance.repo "$(pwd)/vanish/src" &&
|
|
|
|
scalar list >scalar.repos &&
|
|
|
|
grep -F "$(pwd)/vanish/src" scalar.repos &&
|
|
|
|
rm -rf vanish/src/.git &&
|
|
|
|
scalar unregister vanish &&
|
|
|
|
test_must_fail git config --get --global --fixed-value \
|
|
|
|
maintenance.repo "$(pwd)/vanish/src" &&
|
|
|
|
scalar list >scalar.repos &&
|
|
|
|
! grep -F "$(pwd)/vanish/src" scalar.repos
|
|
|
|
'
|
|
|
|
|
2021-12-03 14:34:23 +01:00
|
|
|
test_expect_success 'set up repository to clone' '
|
|
|
|
test_commit first &&
|
|
|
|
test_commit second &&
|
|
|
|
test_commit third &&
|
|
|
|
git switch -c parallel first &&
|
|
|
|
mkdir -p 1/2 &&
|
|
|
|
test_commit 1/2/3 &&
|
|
|
|
git config uploadPack.allowFilter true &&
|
|
|
|
git config uploadPack.allowAnySHA1InWant true
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'scalar clone' '
|
|
|
|
second=$(git rev-parse --verify second:second.t) &&
|
2021-12-03 14:34:24 +01:00
|
|
|
scalar clone "file://$(pwd)" cloned --single-branch &&
|
2021-12-03 14:34:23 +01:00
|
|
|
(
|
|
|
|
cd cloned/src &&
|
|
|
|
|
|
|
|
git config --get --global --fixed-value maintenance.repo \
|
|
|
|
"$(pwd)" &&
|
|
|
|
|
2021-12-03 14:34:24 +01:00
|
|
|
git for-each-ref --format="%(refname)" refs/remotes/origin/ >actual &&
|
|
|
|
echo "refs/remotes/origin/parallel" >expect &&
|
|
|
|
test_cmp expect actual &&
|
|
|
|
|
2021-12-03 14:34:23 +01:00
|
|
|
test_path_is_missing 1/2 &&
|
|
|
|
test_must_fail git rev-list --missing=print $second &&
|
|
|
|
git rev-list $second &&
|
|
|
|
git cat-file blob $second >actual &&
|
|
|
|
echo "second" >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2021-12-03 14:34:26 +01:00
|
|
|
test_expect_success 'scalar reconfigure' '
|
|
|
|
git init one/src &&
|
|
|
|
scalar register one &&
|
|
|
|
git -C one/src config core.preloadIndex false &&
|
|
|
|
scalar reconfigure one &&
|
2021-12-03 14:34:27 +01:00
|
|
|
test true = "$(git -C one/src config core.preloadIndex)" &&
|
|
|
|
git -C one/src config core.preloadIndex false &&
|
|
|
|
scalar reconfigure -a &&
|
2021-12-03 14:34:26 +01:00
|
|
|
test true = "$(git -C one/src config core.preloadIndex)"
|
|
|
|
'
|
|
|
|
|
2021-12-03 14:34:28 +01:00
|
|
|
test_expect_success 'scalar delete without enlistment shows a usage' '
|
|
|
|
test_expect_code 129 scalar delete
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'scalar delete with enlistment' '
|
|
|
|
scalar delete cloned &&
|
|
|
|
test_path_is_missing cloned
|
|
|
|
'
|
|
|
|
|
2022-01-28 15:31:57 +01:00
|
|
|
test_expect_success 'scalar supports -c/-C' '
|
|
|
|
test_when_finished "scalar delete sub" &&
|
|
|
|
git init sub &&
|
|
|
|
scalar -C sub -c status.aheadBehind=bogus register &&
|
|
|
|
test -z "$(git -C sub config --local status.aheadBehind)" &&
|
|
|
|
test true = "$(git -C sub config core.preloadIndex)"
|
|
|
|
'
|
|
|
|
|
2021-12-03 14:34:18 +01:00
|
|
|
test_done
|