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
@@ -3139,18 +3145,20 @@ static void do_req__with_fallback(const char *url_component,
3139
3145
*
3140
3146
* Return server's response buffer. This is probably a raw JSON string.
3141
3147
*/
3142
- static void do__http_get__gvfs_config (struct gh__response_status * status ,
3143
- struct strbuf * config_data )
3148
+ static void do__http_get__simple_endpoint (struct gh__response_status * status ,
3149
+ struct strbuf * response ,
3150
+ const char * endpoint ,
3151
+ const char * tr2_label )
3144
3152
{
3145
3153
struct gh__request_params params = GH__REQUEST_PARAMS_INIT ;
3146
3154
3147
- strbuf_addstr (& params .tr2_label , "GET/config" );
3155
+ strbuf_addstr (& params .tr2_label , tr2_label );
3148
3156
3149
3157
params .b_is_post = 0 ;
3150
3158
params .b_write_to_file = 0 ;
3151
3159
/* cache-servers do not handle gvfs/config REST calls */
3152
3160
params .b_permit_cache_server_if_defined = 0 ;
3153
- params .buffer = config_data ;
3161
+ params .buffer = response ;
3154
3162
params .objects_mode = GH__OBJECTS_MODE__NONE ;
3155
3163
3156
3164
params .object_count = 1 ; /* a bit of a lie */
@@ -3172,15 +3180,22 @@ static void do__http_get__gvfs_config(struct gh__response_status *status,
3172
3180
* see any need to report progress on the upload side of
3173
3181
* the GET. So just report progress on the download side.
3174
3182
*/
3175
- strbuf_addstr (& params .progress_base_phase3_msg ,
3176
- "Receiving gvfs/config" );
3183
+ strbuf_addf (& params .progress_base_phase3_msg ,
3184
+ "Receiving %s" , endpoint );
3177
3185
}
3178
3186
3179
- do_req__with_fallback ("gvfs/config" , & params , status );
3187
+ do_req__with_fallback (endpoint , & params , status );
3180
3188
3181
3189
gh__request_params__release (& params );
3182
3190
}
3183
3191
3192
+ static void do__http_get__gvfs_config (struct gh__response_status * status ,
3193
+ struct strbuf * config_data )
3194
+ {
3195
+ do__http_get__simple_endpoint (status , config_data , "gvfs/config" ,
3196
+ "GET/config" );
3197
+ }
3198
+
3184
3199
static void setup_gvfs_objects_progress (struct gh__request_params * params ,
3185
3200
unsigned long num , unsigned long den )
3186
3201
{
@@ -3625,6 +3640,35 @@ static enum gh__error_code do_sub_cmd__config(int argc UNUSED, const char **argv
3625
3640
return ec ;
3626
3641
}
3627
3642
3643
+ static enum gh__error_code do_sub_cmd__endpoint (int argc , const char * * argv )
3644
+ {
3645
+ struct gh__response_status status = GH__RESPONSE_STATUS_INIT ;
3646
+ struct strbuf data = STRBUF_INIT ;
3647
+ enum gh__error_code ec = GH__ERROR_CODE__OK ;
3648
+ const char * endpoint ;
3649
+
3650
+ if (argc != 2 )
3651
+ return GH__ERROR_CODE__ERROR ;
3652
+ endpoint = argv [1 ];
3653
+
3654
+ trace2_cmd_mode (endpoint );
3655
+
3656
+ finish_init (0 );
3657
+
3658
+ do__http_get__simple_endpoint (& status , & data , endpoint , endpoint );
3659
+ ec = status .ec ;
3660
+
3661
+ if (ec == GH__ERROR_CODE__OK )
3662
+ printf ("%s\n" , data .buf );
3663
+ else
3664
+ error ("config: %s" , status .error_message .buf );
3665
+
3666
+ gh__response_status__release (& status );
3667
+ strbuf_release (& data );
3668
+
3669
+ return ec ;
3670
+ }
3671
+
3628
3672
/*
3629
3673
* Read a list of objects from stdin and fetch them as a series of
3630
3674
* single object HTTP GET requests.
@@ -4117,6 +4161,9 @@ static enum gh__error_code do_sub_cmd(int argc, const char **argv)
4117
4161
if (!strcmp (argv [0 ], "config" ))
4118
4162
return do_sub_cmd__config (argc , argv );
4119
4163
4164
+ if (!strcmp (argv [0 ], "endpoint" ))
4165
+ return do_sub_cmd__endpoint (argc , argv );
4166
+
4120
4167
if (!strcmp (argv [0 ], "prefetch" ))
4121
4168
return do_sub_cmd__prefetch (argc , argv );
4122
4169
0 commit comments