]> git.ipfire.org Git - thirdparty/git.git/blob - contrib/scalar/t/t9099-scalar.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / contrib / scalar / t / t9099-scalar.sh
1 #!/bin/sh
2
3 test_description='test the `scalar` command'
4
5 TEST_DIRECTORY=$PWD/../../../t
6 export TEST_DIRECTORY
7
8 # Make it work with --no-bin-wrappers
9 PATH=$PWD/..:$PATH
10
11 . ../../../t/test-lib.sh
12
13 GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab ../cron.txt,launchctl:true,schtasks:true"
14 export GIT_TEST_MAINT_SCHEDULER
15
16 test_expect_success 'scalar shows a usage' '
17 test_expect_code 129 scalar -h
18 '
19
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
33 '
34
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
44 '
45
46 test_expect_success 'scalar clone' '
47 second=$(git rev-parse --verify second:second.t) &&
48 scalar clone "file://$(pwd)" cloned --single-branch &&
49 (
50 cd cloned/src &&
51
52 git config --get --global --fixed-value maintenance.repo \
53 "$(pwd)" &&
54
55 git for-each-ref --format="%(refname)" refs/remotes/origin/ >actual &&
56 echo "refs/remotes/origin/parallel" >expect &&
57 test_cmp expect actual &&
58
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
65 )
66 '
67
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)"
77 '
78
79 test_expect_success 'scalar delete without enlistment shows a usage' '
80 test_expect_code 129 scalar delete
81 '
82
83 test_expect_success 'scalar delete with enlistment' '
84 scalar delete cloned &&
85 test_path_is_missing cloned
86 '
87
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)"
94 '
95
96 test_expect_success '`scalar [...] <dir>` errors out when dir is missing' '
97 ! scalar run config cloned 2>err &&
98 grep "cloned. does not exist" err
99 '
100
101 SQ="'"
102 test_expect_success UNZIP 'scalar diagnose' '
103 scalar clone "file://$(pwd)" cloned --single-branch &&
104 git repack &&
105 echo "$(pwd)/.git/objects/" >>cloned/src/.git/objects/info/alternates &&
106 test_commit -C cloned/src loose &&
107 scalar diagnose cloned >out 2>err &&
108 grep "Available space" out &&
109 sed -n "s/.*$SQ\\(.*\\.zip\\)$SQ.*/\\1/p" <err >zip_path &&
110 zip_path=$(cat zip_path) &&
111 test -n "$zip_path" &&
112 unzip -v "$zip_path" &&
113 folder=${zip_path%.zip} &&
114 test_path_is_missing "$folder" &&
115 unzip -p "$zip_path" diagnostics.log >out &&
116 test_file_not_empty out &&
117 unzip -p "$zip_path" packs-local.txt >out &&
118 grep "$(pwd)/.git/objects" out &&
119 unzip -p "$zip_path" objects-local.txt >out &&
120 grep "^Total: [1-9]" out
121 '
122
123 test_done