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