@@ -412,6 +412,13 @@ static int get_cache_server_url(struct json_iterator *it)
412
412
return 0 ;
413
413
}
414
414
415
+ static int can_url_support_gvfs (const char * url )
416
+ {
417
+ return starts_with (url , "https://" ) ||
418
+ (git_env_bool ("GIT_TEST_ALLOW_GVFS_VIA_HTTP" , 0 ) &&
419
+ starts_with (url , "http://" ));
420
+ }
421
+
415
422
/*
416
423
* If `cache_server_url` is `NULL`, print the list to `stdout`.
417
424
*
@@ -423,6 +430,13 @@ static int supports_gvfs_protocol(const char *url, char **cache_server_url)
423
430
struct child_process cp = CHILD_PROCESS_INIT ;
424
431
struct strbuf out = STRBUF_INIT ;
425
432
433
+ /*
434
+ * The GVFS protocol is only supported via https://; For testing, we
435
+ * also allow http://.
436
+ */
437
+ if (!can_url_support_gvfs (url ))
438
+ return 0 ;
439
+
426
440
cp .git_cmd = 1 ;
427
441
strvec_pushl (& cp .args , "-c" , "http.version=HTTP/1.1" ,
428
442
"gvfs-helper" , "--remote" , url , "config" , NULL );
@@ -496,19 +510,26 @@ static char *get_cache_key(const char *url)
496
510
struct strbuf out = STRBUF_INIT ;
497
511
char * cache_key = NULL ;
498
512
499
- cp .git_cmd = 1 ;
500
- strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
501
- "endpoint" , "vsts/info" , NULL );
502
- if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
503
- char * id = NULL ;
504
- struct json_iterator it =
505
- JSON_ITERATOR_INIT (out .buf , get_repository_id , & id );
506
-
507
- if (iterate_json (& it ) < 0 )
508
- warning ("JSON parse error (%s)" , out .buf );
509
- else if (id )
510
- cache_key = xstrfmt ("id_%s" , id );
511
- free (id );
513
+ /*
514
+ * The GVFS protocol is only supported via https://; For testing, we
515
+ * also allow http://.
516
+ */
517
+ if (can_url_support_gvfs (url )) {
518
+ cp .git_cmd = 1 ;
519
+ strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
520
+ "endpoint" , "vsts/info" , NULL );
521
+ if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
522
+ char * id = NULL ;
523
+ struct json_iterator it =
524
+ JSON_ITERATOR_INIT (out .buf , get_repository_id ,
525
+ & id );
526
+
527
+ if (iterate_json (& it ) < 0 )
528
+ warning ("JSON parse error (%s)" , out .buf );
529
+ else if (id )
530
+ cache_key = xstrfmt ("id_%s" , id );
531
+ free (id );
532
+ }
512
533
}
513
534
514
535
if (!cache_key ) {
0 commit comments