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