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