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