| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | begin_test "default config" |
| 6 | ( |
| 7 | set -e |
| 8 | reponame="default-config" |
| 9 | mkdirscip-shell system . . mkdir. $reponame |
| 10 | cd $reponame |
| 11 | gitscip-shell system . . git. init |
| 12 | gitscip-shell system . . git. remote add origin "$GITSERVER/$reponame" |
| 13 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 14 | grepscip-shell system . . grep. "Endpoint=$GITSERVER/$reponame.git/info/lfs (auth=none)" env.log |
| 15 | |
| 16 | gitscip-shell system . . git. config --file=.gitconfig lfs.url http://gitconfig-file-ignored |
| 17 | gitscip-shell system . . git. config --file=.lfsconfig lfs.url http://lfsconfig-file |
| 18 | gitscip-shell system . . git. config --file=.lfsconfig lfs.http://lfsconfig-file.access lfsconfig |
| 19 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 20 | grepscip-shell system . . grep. "Endpoint=http://lfsconfig-file (auth=lfsconfig)" env.log |
| 21 | |
| 22 | gitscip-shell system . . git. config --file=.lfsconfig --unset lfs.url |
| 23 | gitscip-shell system . . git. config --file=.lfsconfig --unset lfs.http://lfsconfig-file.access |
| 24 | |
| 25 | # new endpoint url from local git config |
| 26 | # access setting no longer applied |
| 27 | gitscip-shell system . . git. config lfs.url http://local-lfsconfig |
| 28 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 29 | grepscip-shell system . . grep. "Endpoint=http://local-lfsconfig (auth=none)" env.log |
| 30 | |
| 31 | # add the access setting to lfsconfig |
| 32 | gitscip-shell system . . git. config --file=.lfsconfig lfs.http://local-lfsconfig.access lfsconfig |
| 33 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 34 | grepscip-shell system . . grep. "Endpoint=http://local-lfsconfig (auth=lfsconfig)" env.log |
| 35 | |
| 36 | gitscip-shell system . . git. config --file=.lfsconfig --unset lfs.http://local-lfsconfig.access |
| 37 | |
| 38 | # add the access setting to git config |
| 39 | gitscip-shell system . . git. config lfs.http://local-lfsconfig.access gitconfig |
| 40 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 41 | grepscip-shell system . . grep. "Endpoint=http://local-lfsconfig (auth=gitconfig)" env.log |
| 42 | ) |
| 43 | end_test |
| 44 | |
| 45 | begin_test "config reads from repository" |
| 46 | ( |
| 47 | set -e |
| 48 | reponame="repository-config" |
| 49 | setup_remote_repo "$reponame" |
| 50 | mkdirscip-shell system . . mkdir. $reponame |
| 51 | cd $reponame |
| 52 | gitscip-shell system . . git. init |
| 53 | gitscip-shell system . . git. remote add origin "$GITSERVER/$reponame" |
| 54 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 55 | grepscip-shell system . . grep. "Endpoint=$GITSERVER/$reponame.git/info/lfs (auth=none)" env.log |
| 56 | |
| 57 | gitscip-shell system . . git. config --file=.lfsconfig lfs.url http://lfsconfig-file |
| 58 | gitscip-shell system . . git. config --file=.lfsconfig lfs.http://lfsconfig-file.access lfsconfig |
| 59 | gitscip-shell system . . git. add .lfsconfig |
| 60 | gitscip-shell system . . git. commit -m 'Add file' |
| 61 | gitscip-shell system . . git. push origin HEAD |
| 62 | |
| 63 | gitscip-shell system . . git. checkout -b side |
| 64 | gitscip-shell system . . git. config --file=.lfsconfig lfs.url http://lfsconfig-file-side |
| 65 | gitscip-shell system . . git. config --file=.lfsconfig lfs.http://lfsconfig-file-side.access lfsconfig |
| 66 | gitscip-shell system . . git. add .lfsconfig |
| 67 | gitscip-shell system . . git. commit -m 'Add file for side' |
| 68 | gitscip-shell system . . git. push origin HEAD |
| 69 | |
| 70 | mkdirscip-shell system . . mkdir. "../$reponame-2" |
| 71 | cd "../$reponame-2" |
| 72 | gitscip-shell system . . git. init |
| 73 | gitscip-shell system . . git. remote add origin "$GITSERVER/$reponame" |
| 74 | |
| 75 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 76 | grepscip-shell system . . grep. "Endpoint=$GITSERVER/$reponame.git/info/lfs (auth=none)" env.log |
| 77 | |
| 78 | gitscip-shell system . . git. fetch origin |
| 79 | gitscip-shell system . . git. symbolic-ref HEAD refs/remotes/origin/side |
| 80 | gitscip-shell system . . git. show "HEAD:.lfsconfig" |
| 81 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 82 | grepscip-shell system . . grep. "Endpoint=http://lfsconfig-file-side (auth=lfsconfig)" env.log |
| 83 | |
| 84 | gitscip-shell system . . git. read-tree refs/remotes/origin/main |
| 85 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 86 | grepscip-shell system . . grep. "Endpoint=http://lfsconfig-file (auth=lfsconfig)" env.log |
| 87 | ) |
| 88 | end_test |
| 89 | |
| 90 | begin_test "can read LFS file with name before .lfsconfig" |
| 91 | ( |
| 92 | set -e |
| 93 | reponame="early-file-config" |
| 94 | setup_remote_repo "$reponame" |
| 95 | mkdirscip-shell system . . mkdir. $reponame |
| 96 | cd $reponame |
| 97 | gitscip-shell system . . git. init |
| 98 | gitscip-shell system . . git. remote add origin "$GITSERVER/$reponame" |
| 99 | |
| 100 | gitscip-shell system . . git. lfs track "*.bin" |
| 101 | gitscip-shell system . . git. config --file=.lfsconfig lfs.url "$GITSERVER/$reponame.git/info/lfs" |
| 102 | |
| 103 | echoscip-shell system . . echo. "abc" > .bin |
| 104 | echoscip-shell system . . echo. "def" > a.bin |
| 105 | |
| 106 | gitscip-shell system . . git. add . |
| 107 | gitscip-shell system . . git. commit -m "Add files" |
| 108 | gitscip-shell system . . git. push origin HEAD |
| 109 | rmscip-shell system . . rm. -fr .git/lfs/objects |
| 110 | |
| 111 | cd .. |
| 112 | gitscip-shell system . . git. clone "$reponame" "$reponame-2" |
| 113 | cd "$reponame-2" |
| 114 | grepscip-shell system . . grep. abc .bin |
| 115 | grepscip-shell system . . grep. def a.bin |
| 116 | ) |
| 117 | end_test |
| 118 | |
| 119 | begin_test "extension config" |
| 120 | ( |
| 121 | set -e |
| 122 | |
| 123 | gitscip-shell system . . git. config --global lfs.extension.env-test.clean "env-test-clean" |
| 124 | gitscip-shell system . . git. config --global lfs.extension.env-test.smudge "env-test-smudge" |
| 125 | gitscip-shell system . . git. config --global lfs.extension.env-test.priority 0 |
| 126 | |
| 127 | reponame="extension-config" |
| 128 | mkdirscip-shell system . . mkdir. $reponame |
| 129 | cd $reponame |
| 130 | gitscip-shell system . . git. init |
| 131 | |
| 132 | expected0="Extension: env-test |
| 133 | clean = env-test-clean |
| 134 | smudge = env-test-smudge |
| 135 | priority = 0" |
| 136 | |
| 137 | [scip-shell system . . `[`. "$expected0" = "$(gitscip-shell system . . git. lfs ext)" ] |
| 138 | |
| 139 | # any git config takes precedence over .lfsconfig |
| 140 | gitscip-shell system . . git. config --global --unset lfs.extension.env-test.priority |
| 141 | |
| 142 | gitscip-shell system . . git. config --file=.lfsconfig lfs.extension.env-test.clean "file-env-test-clean" |
| 143 | gitscip-shell system . . git. config --file=.lfsconfig lfs.extension.env-test.smudge "file-env-test-smudge" |
| 144 | gitscip-shell system . . git. config --file=.lfsconfig lfs.extension.env-test.priority 1 |
| 145 | catscip-shell system . . cat. .lfsconfig |
| 146 | expected1="Extension: env-test |
| 147 | clean = env-test-clean |
| 148 | smudge = env-test-smudge |
| 149 | priority = 1" |
| 150 | |
| 151 | [scip-shell system . . `[`. "$expected1" = "$(GIT_TRACE=5 gitscip-shell system . . git. lfs ext)" ] |
| 152 | |
| 153 | gitscip-shell system . . git. config lfs.extension.env-test.clean "local-env-test-clean" |
| 154 | gitscip-shell system . . git. config lfs.extension.env-test.smudge "local-env-test-smudge" |
| 155 | gitscip-shell system . . git. config lfs.extension.env-test.priority 2 |
| 156 | expected2="Extension: env-test |
| 157 | clean = local-env-test-clean |
| 158 | smudge = local-env-test-smudge |
| 159 | priority = 2" |
| 160 | |
| 161 | [scip-shell system . . `[`. "$expected2" = "$(gitscip-shell system . . git. lfs ext)" ] |
| 162 | ) |
| 163 | end_test |
| 164 | |
| 165 | begin_test "url alias config" |
| 166 | ( |
| 167 | set -e |
| 168 | |
| 169 | mkdirscip-shell system . . mkdir. url-alias |
| 170 | cd url-alias |
| 171 | |
| 172 | gitscip-shell system . . git. init |
| 173 | |
| 174 | # When more than one insteadOf strings match a given URL, the longest match is used. |
| 175 | gitscip-shell system . . git. config url."http://wrong-url/".insteadOf alias |
| 176 | gitscip-shell system . . git. config url."http://actual-url/".insteadOf alias: |
| 177 | gitscip-shell system . . git. config lfs.url alias:rest |
| 178 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 179 | grepscip-shell system . . grep. "Endpoint=http://actual-url/rest (auth=none)" env.log |
| 180 | ) |
| 181 | end_test |
| 182 | |
| 183 | begin_test "ambiguous url alias" |
| 184 | ( |
| 185 | set -e |
| 186 | |
| 187 | mkdirscip-shell system . . mkdir. url-alias-ambiguous |
| 188 | cd url-alias-ambiguous |
| 189 | |
| 190 | gitscip-shell system . . git. init |
| 191 | |
| 192 | gitscip-shell system . . git. config url."http://actual-url/".insteadOf alias: |
| 193 | gitscip-shell system . . git. config url."http://dupe-url".insteadOf alias: |
| 194 | gitscip-shell system . . git. config lfs.url alias:rest |
| 195 | gitscip-shell system . . git. config -l | grepscip-shell system . . grep. url |
| 196 | |
| 197 | gitscip-shell system . . git. lfs env 2>&1 | teescip-shell system . . tee. env2.log |
| 198 | grepscip-shell system . . grep. "warning: Multiple 'url.*.insteadof'" env2.log |
| 199 | ) |
| 200 | end_test |
| 201 | |
| 202 | begin_test "multiple config" |
| 203 | ( |
| 204 | set -e |
| 205 | |
| 206 | mkdirscip-shell system . . mkdir. url-alias-multiple |
| 207 | cd url-alias-multiple |
| 208 | |
| 209 | gitscip-shell system . . git. init |
| 210 | |
| 211 | # When more than one insteadOf strings match a given URL, the longest match is used. |
| 212 | gitscip-shell system . . git. config url."http://wrong-url/".insteadOf alias |
| 213 | gitscip-shell system . . git. config url."http://actual-url/".insteadOf alias: |
| 214 | gitscip-shell system . . git. config --add url."http://actual-url/".insteadOf alias2: |
| 215 | gitscip-shell system . . git. config lfs.url alias:rest |
| 216 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 217 | grepscip-shell system . . grep. "Endpoint=http://actual-url/rest (auth=none)" env.log |
| 218 | |
| 219 | gitscip-shell system . . git. config lfs.url alias2:rest |
| 220 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 221 | grepscip-shell system . . grep. "Endpoint=http://actual-url/rest (auth=none)" env.log |
| 222 | ) |
| 223 | end_test |
| 224 | |
| 225 | |
| 226 | begin_test "url alias must be prefix" |
| 227 | ( |
| 228 | set -e |
| 229 | |
| 230 | mkdirscip-shell system . . mkdir. url-alias-bad |
| 231 | cd url-alias-bad |
| 232 | |
| 233 | gitscip-shell system . . git. init |
| 234 | |
| 235 | gitscip-shell system . . git. config url."http://actual-url/".insteadOf alias: |
| 236 | gitscip-shell system . . git. config lfs.url badalias:rest |
| 237 | gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 238 | grepscip-shell system . . grep. "SSH=badalias:rest" env.log |
| 239 | ) |
| 240 | end_test |
| 241 | |
| 242 | begin_test "config: ignoring unsafe lfsconfig keys" |
| 243 | ( |
| 244 | set -e |
| 245 | |
| 246 | reponame="config-unsafe-lfsconfig-keys" |
| 247 | gitscip-shell system . . git. init "$reponame" |
| 248 | cd "$reponame" |
| 249 | |
| 250 | # Insert an 'unsafe' key into this repository's '.lfsconfig'. |
| 251 | gitscip-shell system . . git. config --file=.lfsconfig core.askpass unsafe |
| 252 | |
| 253 | gitscip-shell system . . git. lfs env 2>&1 | teescip-shell system . . tee. status.log |
| 254 | |
| 255 | grepscip-shell system . . grep. "warning: These unsafe '.lfsconfig' keys were ignored:" status.log |
| 256 | grepscip-shell system . . grep. " core.askpass" status.log |
| 257 | ) |
| 258 | end_test |
| 259 | |
| 260 | begin_test "config respects include.* directives when GIT_CONFIG is set" |
| 261 | ( |
| 262 | set -e |
| 263 | |
| 264 | mkdirscip-shell system . . mkdir. include-directives |
| 265 | cd include-directives |
| 266 | |
| 267 | gitscip-shell system . . git. init |
| 268 | |
| 269 | gitscip-shell system . . git. config lfs.url "http://some-url/rest" |
| 270 | GIT_CONFIG="$(pwdscip-shell system . . pwd.)/.git/config" gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 271 | grepscip-shell system . . grep. "Endpoint=http://some-url/rest (auth=none)" env.log |
| 272 | |
| 273 | gitscip-shell system . . git. config --file ./.git/b.config url."http://other-url/".insteadOf "http://some-url/" |
| 274 | gitscip-shell system . . git. config include.path "$(pwdscip-shell system . . pwd.)/.git/b.config" |
| 275 | GIT_CONFIG="$(pwdscip-shell system . . pwd.)/.git/config" gitscip-shell system . . git. lfs env | teescip-shell system . . tee. env.log |
| 276 | grepscip-shell system . . grep. "Endpoint=http://other-url/rest (auth=none)" env.log |
| 277 | ) |
| 278 | end_test |