@@ -397,6 +397,13 @@ static int get_cache_server_url(struct json_iterator *it)
397
397
return 0 ;
398
398
}
399
399
400
+ static int can_url_support_gvfs (const char * url )
401
+ {
402
+ return starts_with (url , "https://" ) ||
403
+ (git_env_bool ("GIT_TEST_ALLOW_GVFS_VIA_HTTP" , 0 ) &&
404
+ starts_with (url , "http://" ));
405
+ }
406
+
400
407
/*
401
408
* If `cache_server_url` is `NULL`, print the list to `stdout`.
402
409
*
@@ -408,6 +415,13 @@ static int supports_gvfs_protocol(const char *url, char **cache_server_url)
408
415
struct child_process cp = CHILD_PROCESS_INIT ;
409
416
struct strbuf out = STRBUF_INIT ;
410
417
418
+ /*
419
+ * The GVFS protocol is only supported via https://; For testing, we
420
+ * also allow http://.
421
+ */
422
+ if (!can_url_support_gvfs (url ))
423
+ return 0 ;
424
+
411
425
cp .git_cmd = 1 ;
412
426
strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url , "config" , NULL );
413
427
if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
@@ -480,19 +494,26 @@ static char *get_cache_key(const char *url)
480
494
struct strbuf out = STRBUF_INIT ;
481
495
char * cache_key = NULL ;
482
496
483
- cp .git_cmd = 1 ;
484
- strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
485
- "endpoint" , "vsts/info" , NULL );
486
- if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
487
- char * id = NULL ;
488
- struct json_iterator it =
489
- JSON_ITERATOR_INIT (out .buf , get_repository_id , & id );
490
-
491
- if (iterate_json (& it ) < 0 )
492
- warning ("JSON parse error (%s)" , out .buf );
493
- else if (id )
494
- cache_key = xstrfmt ("id_%s" , id );
495
- free (id );
497
+ /*
498
+ * The GVFS protocol is only supported via https://; For testing, we
499
+ * also allow http://.
500
+ */
501
+ if (can_url_support_gvfs (url )) {
502
+ cp .git_cmd = 1 ;
503
+ strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
504
+ "endpoint" , "vsts/info" , NULL );
505
+ if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
506
+ char * id = NULL ;
507
+ struct json_iterator it =
508
+ JSON_ITERATOR_INIT (out .buf , get_repository_id ,
509
+ & id );
510
+
511
+ if (iterate_json (& it ) < 0 )
512
+ warning ("JSON parse error (%s)" , out .buf );
513
+ else if (id )
514
+ cache_key = xstrfmt ("id_%s" , id );
515
+ free (id );
516
+ }
496
517
}
497
518
498
519
if (!cache_key ) {
0 commit comments