scalar: accept -C and -c options before the subcommand
[git/debian.git] / contrib / scalar / t / t9099-scalar.sh
blob89781568f43abf301b6df3a932b064c44ecd3e80
1 #!/bin/sh
3 test_description='test the `scalar` command'
5 TEST_DIRECTORY=$PWD/../../../t
6 export TEST_DIRECTORY
8 # Make it work with --no-bin-wrappers
9 PATH=$PWD/..:$PATH
11 . ../../../t/test-lib.sh
13 GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab ../cron.txt,launchctl:true,schtasks:true"
14 export GIT_TEST_MAINT_SCHEDULER
16 test_expect_success 'scalar shows a usage' '
17 test_expect_code 129 scalar -h
20 test_expect_success 'scalar unregister' '
21 git init vanish/src &&
22 scalar register vanish/src &&
23 git config --get --global --fixed-value \
24 maintenance.repo "$(pwd)/vanish/src" &&
25 scalar list >scalar.repos &&
26 grep -F "$(pwd)/vanish/src" scalar.repos &&
27 rm -rf vanish/src/.git &&
28 scalar unregister vanish &&
29 test_must_fail git config --get --global --fixed-value \
30 maintenance.repo "$(pwd)/vanish/src" &&
31 scalar list >scalar.repos &&
32 ! grep -F "$(pwd)/vanish/src" scalar.repos
35 test_expect_success 'set up repository to clone' '
36 test_commit first &&
37 test_commit second &&
38 test_commit third &&
39 git switch -c parallel first &&
40 mkdir -p 1/2 &&
41 test_commit 1/2/3 &&
42 git config uploadPack.allowFilter true &&
43 git config uploadPack.allowAnySHA1InWant true
46 test_expect_success 'scalar clone' '
47 second=$(git rev-parse --verify second:second.t) &&
48 scalar clone "file://$(pwd)" cloned --single-branch &&
50 cd cloned/src &&
52 git config --get --global --fixed-value maintenance.repo \
53 "$(pwd)" &&
55 git for-each-ref --format="%(refname)" refs/remotes/origin/ >actual &&
56 echo "refs/remotes/origin/parallel" >expect &&
57 test_cmp expect actual &&
59 test_path_is_missing 1/2 &&
60 test_must_fail git rev-list --missing=print $second &&
61 git rev-list $second &&
62 git cat-file blob $second >actual &&
63 echo "second" >expect &&
64 test_cmp expect actual
68 test_expect_success 'scalar reconfigure' '
69 git init one/src &&
70 scalar register one &&
71 git -C one/src config core.preloadIndex false &&
72 scalar reconfigure one &&
73 test true = "$(git -C one/src config core.preloadIndex)" &&
74 git -C one/src config core.preloadIndex false &&
75 scalar reconfigure -a &&
76 test true = "$(git -C one/src config core.preloadIndex)"
79 test_expect_success 'scalar delete without enlistment shows a usage' '
80 test_expect_code 129 scalar delete
83 test_expect_success 'scalar delete with enlistment' '
84 scalar delete cloned &&
85 test_path_is_missing cloned
88 test_expect_success 'scalar supports -c/-C' '
89 test_when_finished "scalar delete sub" &&
90 git init sub &&
91 scalar -C sub -c status.aheadBehind=bogus register &&
92 test -z "$(git -C sub config --local status.aheadBehind)" &&
93 test true = "$(git -C sub config core.preloadIndex)"
96 test_done