@@ -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 )) {
@@ -476,19 +490,26 @@ static char *get_cache_key(const char *url)
476
490
struct strbuf out = STRBUF_INIT ;
477
491
char * cache_key = NULL ;
478
492
479
- cp .git_cmd = 1 ;
480
- strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
481
- "endpoint" , "vsts/info" , NULL );
482
- if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
483
- char * id = NULL ;
484
- struct json_iterator it =
485
- JSON_ITERATOR_INIT (out .buf , get_repository_id , & id );
486
-
487
- if (iterate_json (& it ) < 0 )
488
- warning ("JSON parse error (%s)" , out .buf );
489
- else if (id )
490
- cache_key = xstrfmt ("id_%s" , id );
491
- free (id );
493
+ /*
494
+ * The GVFS protocol is only supported via https://; For testing, we
495
+ * also allow http://.
496
+ */
497
+ if (can_url_support_gvfs (url )) {
498
+ cp .git_cmd = 1 ;
499
+ strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
500
+ "endpoint" , "vsts/info" , NULL );
501
+ if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
502
+ char * id = NULL ;
503
+ struct json_iterator it =
504
+ JSON_ITERATOR_INIT (out .buf , get_repository_id ,
505
+ & 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 );
512
+ }
492
513
}
493
514
494
515
if (!cache_key ) {
0 commit comments