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