@@ -327,4 +327,161 @@ test_expect_success UNZIP 'scalar diagnose' '
327327 grep "^Total: [1-9]" out
328328'
329329
330+ GIT_TEST_ALLOW_GVFS_VIA_HTTP=1
331+ export GIT_TEST_ALLOW_GVFS_VIA_HTTP
332+
333+ test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
334+ HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_PORT
335+ PID_FILE=" $( pwd) " /pid-file.pid
336+ SERVER_LOG=" $( pwd) " /OUT.server.log
337+
338+ test_atexit '
339+ test -f "$PID_FILE" || return 0
340+
341+ # The server will shutdown automatically when we delete the pid-file.
342+ rm -f "$PID_FILE"
343+
344+ test -z "$verbose$verbose_log" || {
345+ echo "server log:"
346+ cat "$SERVER_LOG"
347+ }
348+
349+ # Give it a few seconds to shutdown (mainly to completely release the
350+ # port before the next test start another instance and it attempts to
351+ # bind to it).
352+ for k in $(test_seq 5)
353+ do
354+ grep -q "Starting graceful shutdown" "$SERVER_LOG" &&
355+ return 0 ||
356+ sleep 1
357+ done
358+
359+ echo "stop_gvfs_protocol_server: timeout waiting for server shutdown"
360+ return 1
361+ '
362+
363+ start_gvfs_enabled_http_server () {
364+ GIT_HTTP_EXPORT_ALL=1 \
365+ test-gvfs-protocol --verbose \
366+ --listen=127.0.0.1 \
367+ --port=$GIT_TEST_GVFS_PROTOCOL_PORT \
368+ --reuseaddr \
369+ --pid-file=" $PID_FILE " \
370+ 2> " $SERVER_LOG " &
371+
372+ for k in 0 1 2 3 4
373+ do
374+ if test -f " $PID_FILE "
375+ then
376+ return 0
377+ fi
378+ sleep 1
379+ done
380+ return 1
381+ }
382+
383+ test_expect_success ' start GVFS-enabled server' '
384+ git config uploadPack.allowFilter false &&
385+ git config uploadPack.allowAnySHA1InWant false &&
386+ start_gvfs_enabled_http_server
387+ '
388+
389+ test_expect_success ' `scalar clone` with GVFS-enabled server' '
390+ : the fake cache server requires fake authentication &&
391+ git config --global core.askPass true &&
392+
393+ # We must set credential.interactive=true to bypass a setting
394+ # in "scalar clone" that disables interactive credentials during
395+ # an unattended command.
396+ scalar -c credential.interactive=true clone --single-branch -- http://$HOST_PORT/ using-gvfs &&
397+
398+ : verify that the shared cache has been configured &&
399+ cache_key="url_$(printf "%s" http://$HOST_PORT/ |
400+ tr A-Z a-z |
401+ test-tool sha1)" &&
402+ echo "$(pwd)/.scalarCache/$cache_key" >expect &&
403+ git -C using-gvfs/src config gvfs.sharedCache >actual &&
404+ test_cmp expect actual &&
405+
406+ second=$(git rev-parse --verify second:second.t) &&
407+ (
408+ cd using-gvfs/src &&
409+ test_path_is_missing 1/2 &&
410+ GIT_TRACE=$PWD/trace.txt git cat-file blob $second >actual &&
411+ : verify that the gvfs-helper was invoked to fetch it &&
412+ test_grep gvfs-helper trace.txt &&
413+ echo "second" >expect &&
414+ test_cmp expect actual
415+ )
416+ '
417+
418+ test_expect_success ' `scalar register` parallel to worktree is unsupported' '
419+ git init test-repo/src &&
420+ mkdir -p test-repo/out &&
421+
422+ : parallel to worktree is unsupported &&
423+ test_must_fail env GIT_CEILING_DIRECTORIES="$(pwd)" \
424+ scalar register test-repo/out &&
425+ test_must_fail git config --get --global --fixed-value \
426+ maintenance.repo "$(pwd)/test-repo/src" &&
427+ scalar list >scalar.repos &&
428+ ! grep -F "$(pwd)/test-repo/src" scalar.repos &&
429+
430+ : at enlistment root, i.e. parent of repository, is supported &&
431+ GIT_CEILING_DIRECTORIES="$(pwd)" scalar register test-repo &&
432+ git config --get --global --fixed-value \
433+ maintenance.repo "$(pwd)/test-repo/src" &&
434+ scalar list >scalar.repos &&
435+ grep -F "$(pwd)/test-repo/src" scalar.repos &&
436+
437+ : scalar delete properly unregisters enlistment &&
438+ scalar delete test-repo &&
439+ test_must_fail git config --get --global --fixed-value \
440+ maintenance.repo "$(pwd)/test-repo/src" &&
441+ scalar list >scalar.repos &&
442+ ! grep -F "$(pwd)/test-repo/src" scalar.repos
443+ '
444+
445+ test_expect_success ' `scalar register` & `unregister` with existing repo' '
446+ git init existing &&
447+ scalar register existing &&
448+ git config --get --global --fixed-value \
449+ maintenance.repo "$(pwd)/existing" &&
450+ scalar list >scalar.repos &&
451+ grep -F "$(pwd)/existing" scalar.repos &&
452+ scalar unregister existing &&
453+ test_must_fail git config --get --global --fixed-value \
454+ maintenance.repo "$(pwd)/existing" &&
455+ scalar list >scalar.repos &&
456+ ! grep -F "$(pwd)/existing" scalar.repos
457+ '
458+
459+ test_expect_success ' `scalar unregister` with existing repo, deleted .git' '
460+ scalar register existing &&
461+ rm -rf existing/.git &&
462+ scalar unregister existing &&
463+ test_must_fail git config --get --global --fixed-value \
464+ maintenance.repo "$(pwd)/existing" &&
465+ scalar list >scalar.repos &&
466+ ! grep -F "$(pwd)/existing" scalar.repos
467+ '
468+
469+ test_expect_success ' `scalar register` existing repo with `src` folder' '
470+ git init existing &&
471+ mkdir -p existing/src &&
472+ scalar register existing/src &&
473+ scalar list >scalar.repos &&
474+ grep -F "$(pwd)/existing" scalar.repos &&
475+ scalar unregister existing &&
476+ scalar list >scalar.repos &&
477+ ! grep -F "$(pwd)/existing" scalar.repos
478+ '
479+
480+ test_expect_success ' `scalar delete` with existing repo' '
481+ git init existing &&
482+ scalar register existing &&
483+ scalar delete existing &&
484+ test_path_is_missing existing
485+ '
486+
330487test_done
0 commit comments