202
202
// [2] Documentation/technical/long-running-process-protocol.txt
203
203
// [3] See GIT_TRACE_PACKET
204
204
//
205
+ // endpoint
206
+ //
207
+ // Fetch the given endpoint from the main Git server (specifying
208
+ // `gvfs/config` as endpoint is idempotent to the `config`
209
+ // command mentioned above).
210
+ //
205
211
//////////////////////////////////////////////////////////////////
206
212
207
213
#define USE_THE_REPOSITORY_VARIABLE
@@ -3128,18 +3134,20 @@ static void do_req__with_fallback(const char *url_component,
3128
3134
*
3129
3135
* Return server's response buffer. This is probably a raw JSON string.
3130
3136
*/
3131
- static void do__http_get__gvfs_config (struct gh__response_status * status ,
3132
- struct strbuf * config_data )
3137
+ static void do__http_get__simple_endpoint (struct gh__response_status * status ,
3138
+ struct strbuf * response ,
3139
+ const char * endpoint ,
3140
+ const char * tr2_label )
3133
3141
{
3134
3142
struct gh__request_params params = GH__REQUEST_PARAMS_INIT ;
3135
3143
3136
- strbuf_addstr (& params .tr2_label , "GET/config" );
3144
+ strbuf_addstr (& params .tr2_label , tr2_label );
3137
3145
3138
3146
params .b_is_post = 0 ;
3139
3147
params .b_write_to_file = 0 ;
3140
3148
/* cache-servers do not handle gvfs/config REST calls */
3141
3149
params .b_permit_cache_server_if_defined = 0 ;
3142
- params .buffer = config_data ;
3150
+ params .buffer = response ;
3143
3151
params .objects_mode = GH__OBJECTS_MODE__NONE ;
3144
3152
3145
3153
params .object_count = 1 ; /* a bit of a lie */
@@ -3161,15 +3169,22 @@ static void do__http_get__gvfs_config(struct gh__response_status *status,
3161
3169
* see any need to report progress on the upload side of
3162
3170
* the GET. So just report progress on the download side.
3163
3171
*/
3164
- strbuf_addstr (& params .progress_base_phase3_msg ,
3165
- "Receiving gvfs/config" );
3172
+ strbuf_addf (& params .progress_base_phase3_msg ,
3173
+ "Receiving %s" , endpoint );
3166
3174
}
3167
3175
3168
- do_req__with_fallback ("gvfs/config" , & params , status );
3176
+ do_req__with_fallback (endpoint , & params , status );
3169
3177
3170
3178
gh__request_params__release (& params );
3171
3179
}
3172
3180
3181
+ static void do__http_get__gvfs_config (struct gh__response_status * status ,
3182
+ struct strbuf * config_data )
3183
+ {
3184
+ do__http_get__simple_endpoint (status , config_data , "gvfs/config" ,
3185
+ "GET/config" );
3186
+ }
3187
+
3173
3188
static void setup_gvfs_objects_progress (struct gh__request_params * params ,
3174
3189
unsigned long num , unsigned long den )
3175
3190
{
@@ -3614,6 +3629,35 @@ static enum gh__error_code do_sub_cmd__config(int argc UNUSED, const char **argv
3614
3629
return ec ;
3615
3630
}
3616
3631
3632
+ static enum gh__error_code do_sub_cmd__endpoint (int argc , const char * * argv )
3633
+ {
3634
+ struct gh__response_status status = GH__RESPONSE_STATUS_INIT ;
3635
+ struct strbuf data = STRBUF_INIT ;
3636
+ enum gh__error_code ec = GH__ERROR_CODE__OK ;
3637
+ const char * endpoint ;
3638
+
3639
+ if (argc != 2 )
3640
+ return GH__ERROR_CODE__ERROR ;
3641
+ endpoint = argv [1 ];
3642
+
3643
+ trace2_cmd_mode (endpoint );
3644
+
3645
+ finish_init (0 );
3646
+
3647
+ do__http_get__simple_endpoint (& status , & data , endpoint , endpoint );
3648
+ ec = status .ec ;
3649
+
3650
+ if (ec == GH__ERROR_CODE__OK )
3651
+ printf ("%s\n" , data .buf );
3652
+ else
3653
+ error ("config: %s" , status .error_message .buf );
3654
+
3655
+ gh__response_status__release (& status );
3656
+ strbuf_release (& data );
3657
+
3658
+ return ec ;
3659
+ }
3660
+
3617
3661
/*
3618
3662
* Read a list of objects from stdin and fetch them as a series of
3619
3663
* single object HTTP GET requests.
@@ -4106,6 +4150,9 @@ static enum gh__error_code do_sub_cmd(int argc, const char **argv)
4106
4150
if (!strcmp (argv [0 ], "config" ))
4107
4151
return do_sub_cmd__config (argc , argv );
4108
4152
4153
+ if (!strcmp (argv [0 ], "endpoint" ))
4154
+ return do_sub_cmd__endpoint (argc , argv );
4155
+
4109
4156
if (!strcmp (argv [0 ], "prefetch" ))
4110
4157
return do_sub_cmd__prefetch (argc , argv );
4111
4158
0 commit comments