Skip to content

Commit 9bf4193

Browse files
committed
scalar: verify that we can use a GVFS-enabled repository
Azure Repos does not support partial clones at the moment, but it does support the GVFS protocol. To that end, the Microsoft fork of Git has a `gvfs-helper` command that is optionally used to perform essentially the same functionality as partial clone. Let's verify that `scalar clone` detects that situation and enables the GVFS helper. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent f75fc99 commit 9bf4193

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

t/t9210-scalar.sh

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,157 @@ test_expect_success UNZIP 'scalar diagnose' '
238238
grep "^Total: [1-9]" out
239239
'
240240

241+
GIT_TEST_ALLOW_GVFS_VIA_HTTP=1
242+
export GIT_TEST_ALLOW_GVFS_VIA_HTTP
243+
244+
test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
245+
HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_PORT
246+
PID_FILE="$(pwd)"/pid-file.pid
247+
SERVER_LOG="$(pwd)"/OUT.server.log
248+
249+
test_atexit '
250+
test -f "$PID_FILE" || return 0
251+
252+
# The server will shutdown automatically when we delete the pid-file.
253+
rm -f "$PID_FILE"
254+
255+
test -z "$verbose$verbose_log" || {
256+
echo "server log:"
257+
cat "$SERVER_LOG"
258+
}
259+
260+
# Give it a few seconds to shutdown (mainly to completely release the
261+
# port before the next test start another instance and it attempts to
262+
# bind to it).
263+
for k in $(test_seq 5)
264+
do
265+
grep -q "Starting graceful shutdown" "$SERVER_LOG" &&
266+
return 0 ||
267+
sleep 1
268+
done
269+
270+
echo "stop_gvfs_protocol_server: timeout waiting for server shutdown"
271+
return 1
272+
'
273+
274+
start_gvfs_enabled_http_server () {
275+
GIT_HTTP_EXPORT_ALL=1 \
276+
test-gvfs-protocol --verbose \
277+
--listen=127.0.0.1 \
278+
--port=$GIT_TEST_GVFS_PROTOCOL_PORT \
279+
--reuseaddr \
280+
--pid-file="$PID_FILE" \
281+
2>"$SERVER_LOG" &
282+
283+
for k in 0 1 2 3 4
284+
do
285+
if test -f "$PID_FILE"
286+
then
287+
return 0
288+
fi
289+
sleep 1
290+
done
291+
return 1
292+
}
293+
294+
test_expect_success 'start GVFS-enabled server' '
295+
git config uploadPack.allowFilter false &&
296+
git config uploadPack.allowAnySHA1InWant false &&
297+
start_gvfs_enabled_http_server
298+
'
299+
300+
test_expect_success '`scalar clone` with GVFS-enabled server' '
301+
: the fake cache server requires fake authentication &&
302+
git config --global core.askPass true &&
303+
scalar clone --single-branch -- http://$HOST_PORT/ using-gvfs &&
304+
305+
: verify that the shared cache has been configured &&
306+
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
307+
tr A-Z a-z |
308+
test-tool sha1)" &&
309+
echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect &&
310+
git -C using-gvfs/src config gvfs.sharedCache >actual &&
311+
test_cmp expect actual &&
312+
313+
second=$(git rev-parse --verify second:second.t) &&
314+
(
315+
cd using-gvfs/src &&
316+
test_path_is_missing 1/2 &&
317+
GIT_TRACE=$PWD/trace.txt git cat-file blob $second >actual &&
318+
: verify that the gvfs-helper was invoked to fetch it &&
319+
test_i18ngrep gvfs-helper trace.txt &&
320+
echo "second" >expect &&
321+
test_cmp expect actual
322+
)
323+
'
324+
325+
test_expect_success '`scalar register` parallel to worktree is unsupported' '
326+
git init test-repo/src &&
327+
mkdir -p test-repo/out &&
328+
329+
: parallel to worktree is unsupported &&
330+
test_must_fail env GIT_CEILING_DIRECTORIES="$(pwd)" \
331+
scalar register test-repo/out &&
332+
test_must_fail git config --get --global --fixed-value \
333+
maintenance.repo "$(pwd)/test-repo/src" &&
334+
scalar list >scalar.repos &&
335+
! grep -F "$(pwd)/test-repo/src" scalar.repos &&
336+
337+
: at enlistment root, i.e. parent of repository, is supported &&
338+
GIT_CEILING_DIRECTORIES="$(pwd)" scalar register test-repo &&
339+
git config --get --global --fixed-value \
340+
maintenance.repo "$(pwd)/test-repo/src" &&
341+
scalar list >scalar.repos &&
342+
grep -F "$(pwd)/test-repo/src" scalar.repos &&
343+
344+
: scalar delete properly unregisters enlistment &&
345+
scalar delete test-repo &&
346+
test_must_fail git config --get --global --fixed-value \
347+
maintenance.repo "$(pwd)/test-repo/src" &&
348+
scalar list >scalar.repos &&
349+
! grep -F "$(pwd)/test-repo/src" scalar.repos
350+
'
351+
352+
test_expect_success '`scalar register` & `unregister` with existing repo' '
353+
git init existing &&
354+
scalar register existing &&
355+
git config --get --global --fixed-value \
356+
maintenance.repo "$(pwd)/existing" &&
357+
scalar list >scalar.repos &&
358+
grep -F "$(pwd)/existing" scalar.repos &&
359+
scalar unregister existing &&
360+
test_must_fail git config --get --global --fixed-value \
361+
maintenance.repo "$(pwd)/existing" &&
362+
scalar list >scalar.repos &&
363+
! grep -F "$(pwd)/existing" scalar.repos
364+
'
365+
366+
test_expect_success '`scalar unregister` with existing repo, deleted .git' '
367+
scalar register existing &&
368+
rm -rf existing/.git &&
369+
scalar unregister existing &&
370+
test_must_fail git config --get --global --fixed-value \
371+
maintenance.repo "$(pwd)/existing" &&
372+
scalar list >scalar.repos &&
373+
! grep -F "$(pwd)/existing" scalar.repos
374+
'
375+
376+
test_expect_success '`scalar register` existing repo with `src` folder' '
377+
git init existing &&
378+
mkdir -p existing/src &&
379+
scalar register existing/src &&
380+
scalar list >scalar.repos &&
381+
grep -F "$(pwd)/existing" scalar.repos &&
382+
scalar unregister existing &&
383+
scalar list >scalar.repos &&
384+
! grep -F "$(pwd)/existing" scalar.repos
385+
'
386+
387+
test_expect_success '`scalar delete` with existing repo' '
388+
git init existing &&
389+
scalar register existing &&
390+
scalar delete existing &&
391+
test_path_is_missing existing
392+
'
393+
241394
test_done

0 commit comments

Comments
 (0)