Skip to content

Commit

Permalink
scalar: verify that we can use a GVFS-enabled repository
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Aug 16, 2023
1 parent f04ab23 commit 94b2296
Showing 1 changed file with 153 additions and 0 deletions.
153 changes: 153 additions & 0 deletions t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,157 @@ test_expect_success UNZIP 'scalar diagnose' '
grep "^Total: [1-9]" out
'

GIT_TEST_ALLOW_GVFS_VIA_HTTP=1
export GIT_TEST_ALLOW_GVFS_VIA_HTTP

test_set_port GIT_TEST_GVFS_PROTOCOL_PORT
HOST_PORT=127.0.0.1:$GIT_TEST_GVFS_PROTOCOL_PORT
PID_FILE="$(pwd)"/pid-file.pid
SERVER_LOG="$(pwd)"/OUT.server.log

test_atexit '
test -f "$PID_FILE" || return 0
# The server will shutdown automatically when we delete the pid-file.
rm -f "$PID_FILE"
test -z "$verbose$verbose_log" || {
echo "server log:"
cat "$SERVER_LOG"
}
# Give it a few seconds to shutdown (mainly to completely release the
# port before the next test start another instance and it attempts to
# bind to it).
for k in $(test_seq 5)
do
grep -q "Starting graceful shutdown" "$SERVER_LOG" &&
return 0 ||
sleep 1
done
echo "stop_gvfs_protocol_server: timeout waiting for server shutdown"
return 1
'

start_gvfs_enabled_http_server () {
GIT_HTTP_EXPORT_ALL=1 \
test-gvfs-protocol --verbose \
--listen=127.0.0.1 \
--port=$GIT_TEST_GVFS_PROTOCOL_PORT \
--reuseaddr \
--pid-file="$PID_FILE" \
2>"$SERVER_LOG" &

for k in 0 1 2 3 4
do
if test -f "$PID_FILE"
then
return 0
fi
sleep 1
done
return 1
}

test_expect_success 'start GVFS-enabled server' '
git config uploadPack.allowFilter false &&
git config uploadPack.allowAnySHA1InWant false &&
start_gvfs_enabled_http_server
'

test_expect_success '`scalar clone` with GVFS-enabled server' '
: the fake cache server requires fake authentication &&
git config --global core.askPass true &&
scalar clone --single-branch -- http://$HOST_PORT/ using-gvfs &&
: verify that the shared cache has been configured &&
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
tr A-Z a-z |
test-tool sha1)" &&
echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect &&
git -C using-gvfs/src config gvfs.sharedCache >actual &&
test_cmp expect actual &&
second=$(git rev-parse --verify second:second.t) &&
(
cd using-gvfs/src &&
test_path_is_missing 1/2 &&
GIT_TRACE=$PWD/trace.txt git cat-file blob $second >actual &&
: verify that the gvfs-helper was invoked to fetch it &&
test_i18ngrep gvfs-helper trace.txt &&
echo "second" >expect &&
test_cmp expect actual
)
'

test_expect_success '`scalar register` parallel to worktree is unsupported' '
git init test-repo/src &&
mkdir -p test-repo/out &&
: parallel to worktree is unsupported &&
test_must_fail env GIT_CEILING_DIRECTORIES="$(pwd)" \
scalar register test-repo/out &&
test_must_fail git config --get --global --fixed-value \
maintenance.repo "$(pwd)/test-repo/src" &&
scalar list >scalar.repos &&
! grep -F "$(pwd)/test-repo/src" scalar.repos &&
: at enlistment root, i.e. parent of repository, is supported &&
GIT_CEILING_DIRECTORIES="$(pwd)" scalar register test-repo &&
git config --get --global --fixed-value \
maintenance.repo "$(pwd)/test-repo/src" &&
scalar list >scalar.repos &&
grep -F "$(pwd)/test-repo/src" scalar.repos &&
: scalar delete properly unregisters enlistment &&
scalar delete test-repo &&
test_must_fail git config --get --global --fixed-value \
maintenance.repo "$(pwd)/test-repo/src" &&
scalar list >scalar.repos &&
! grep -F "$(pwd)/test-repo/src" scalar.repos
'

test_expect_success '`scalar register` & `unregister` with existing repo' '
git init existing &&
scalar register existing &&
git config --get --global --fixed-value \
maintenance.repo "$(pwd)/existing" &&
scalar list >scalar.repos &&
grep -F "$(pwd)/existing" scalar.repos &&
scalar unregister existing &&
test_must_fail git config --get --global --fixed-value \
maintenance.repo "$(pwd)/existing" &&
scalar list >scalar.repos &&
! grep -F "$(pwd)/existing" scalar.repos
'

test_expect_success '`scalar unregister` with existing repo, deleted .git' '
scalar register existing &&
rm -rf existing/.git &&
scalar unregister existing &&
test_must_fail git config --get --global --fixed-value \
maintenance.repo "$(pwd)/existing" &&
scalar list >scalar.repos &&
! grep -F "$(pwd)/existing" scalar.repos
'

test_expect_success '`scalar register` existing repo with `src` folder' '
git init existing &&
mkdir -p existing/src &&
scalar register existing/src &&
scalar list >scalar.repos &&
grep -F "$(pwd)/existing" scalar.repos &&
scalar unregister existing &&
scalar list >scalar.repos &&
! grep -F "$(pwd)/existing" scalar.repos
'

test_expect_success '`scalar delete` with existing repo' '
git init existing &&
scalar register existing &&
scalar delete existing &&
test_path_is_missing existing
'

test_done

0 comments on commit 94b2296

Please sign in to comment.