@@ -41,6 +41,7 @@ static long curl_low_speed_time = -1;
4141static int curl_ftp_no_epsv ;
4242static const char * curl_http_proxy ;
4343static char * user_name , * user_pass ;
44+ static const char * user_agent ;
4445
4546#if LIBCURL_VERSION_NUM >= 0x071700
4647/* Use CURLOPT_KEYPASSWD as is */
@@ -196,6 +197,9 @@ static int http_options(const char *var, const char *value, void *cb)
196197 return 0 ;
197198 }
198199
200+ if (!strcmp ("http.useragent" , var ))
201+ return git_config_string (& user_agent , var , value );
202+
199203 /* Fall back on the default ones */
200204 return git_default_config (var , value , cb );
201205}
@@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)
279283 if (getenv ("GIT_CURL_VERBOSE" ))
280284 curl_easy_setopt (result , CURLOPT_VERBOSE , 1 );
281285
282- curl_easy_setopt (result , CURLOPT_USERAGENT , GIT_USER_AGENT );
286+ curl_easy_setopt (result , CURLOPT_USERAGENT ,
287+ user_agent ? user_agent : GIT_HTTP_USER_AGENT );
283288
284289 if (curl_ftp_no_epsv )
285290 curl_easy_setopt (result , CURLOPT_FTP_USE_EPSV , 0 );
@@ -380,6 +385,8 @@ void http_init(struct remote *remote)
380385#endif
381386 set_from_env (& ssl_cainfo , "GIT_SSL_CAINFO" );
382387
388+ set_from_env (& user_agent , "GIT_HTTP_USER_AGENT" );
389+
383390 low_speed_limit = getenv ("GIT_HTTP_LOW_SPEED_LIMIT" );
384391 if (low_speed_limit != NULL )
385392 curl_low_speed_limit = strtol (low_speed_limit , NULL , 10 );
0 commit comments