@@ -414,6 +414,13 @@ static int get_cache_server_url(struct json_iterator *it)
414414 return 0 ;
415415}
416416
417+ static int can_url_support_gvfs (const char * url )
418+ {
419+ return starts_with (url , "https://" ) ||
420+ (git_env_bool ("GIT_TEST_ALLOW_GVFS_VIA_HTTP" , 0 ) &&
421+ starts_with (url , "http://" ));
422+ }
423+
417424/*
418425 * If `cache_server_url` is `NULL`, print the list to `stdout`.
419426 *
@@ -425,6 +432,13 @@ static int supports_gvfs_protocol(const char *url, char **cache_server_url)
425432 struct child_process cp = CHILD_PROCESS_INIT ;
426433 struct strbuf out = STRBUF_INIT ;
427434
435+ /*
436+ * The GVFS protocol is only supported via https://; For testing, we
437+ * also allow http://.
438+ */
439+ if (!can_url_support_gvfs (url ))
440+ return 0 ;
441+
428442 cp .git_cmd = 1 ;
429443 strvec_pushl (& cp .args , "-c" , "http.version=HTTP/1.1" ,
430444 "gvfs-helper" , "--remote" , url , "config" , NULL );
@@ -503,19 +517,26 @@ static char *get_cache_key(const char *url)
503517 struct strbuf out = STRBUF_INIT ;
504518 char * cache_key = NULL ;
505519
506- cp .git_cmd = 1 ;
507- strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
508- "endpoint" , "vsts/info" , NULL );
509- if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
510- char * id = NULL ;
511- struct json_iterator it =
512- JSON_ITERATOR_INIT (out .buf , get_repository_id , & id );
513-
514- if (iterate_json (& it ) < 0 )
515- warning ("JSON parse error (%s)" , out .buf );
516- else if (id )
517- cache_key = xstrfmt ("id_%s" , id );
518- free (id );
520+ /*
521+ * The GVFS protocol is only supported via https://; For testing, we
522+ * also allow http://.
523+ */
524+ if (can_url_support_gvfs (url )) {
525+ cp .git_cmd = 1 ;
526+ strvec_pushl (& cp .args , "gvfs-helper" , "--remote" , url ,
527+ "endpoint" , "vsts/info" , NULL );
528+ if (!pipe_command (& cp , NULL , 0 , & out , 512 , NULL , 0 )) {
529+ char * id = NULL ;
530+ struct json_iterator it =
531+ JSON_ITERATOR_INIT (out .buf , get_repository_id ,
532+ & id );
533+
534+ if (iterate_json (& it ) < 0 )
535+ warning ("JSON parse error (%s)" , out .buf );
536+ else if (id )
537+ cache_key = xstrfmt ("id_%s" , id );
538+ free (id );
539+ }
519540 }
520541
521542 if (!cache_key ) {
0 commit comments