@matheusbsbs / matheus-bagliano / commits / 380792390e
Fork 0

Set the parallel HTTP request limit via an environment variable

Use an environment variable rather than a command-line argument to set the parallel HTTP request limit. This allows the setting to work whether git-http-fetch is run directly or via git-fetch. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nick Hengeveld committed Oct 10, 2005 at 23:22 UTC 380792390e05e744f9d7eefbc35d1db80e44e27a
1 file changed +6 -11
http-fetch.c
+6 -11
@@ -1034,22 +1034,11 @@ int main(int argc, char **argv)
1034 arg++;
1035 } else if (!strcmp(argv[arg], "--recover")) {
1036 get_recover = 1;
1037 -#ifdef USE_CURL_MULTI
1038 - } else if (argv[arg][1] == 'r') {
1039 - max_requests = atoi(argv[arg + 1]);
1040 - if (max_requests < 1)
1041 - max_requests = DEFAULT_MAX_REQUESTS;
1042 - arg++;
1043 -#endif
1037 }
1038 arg++;
1039 }
1040 if (argc < arg + 2) {
1048 -#ifdef USE_CURL_MULTI
1049 - usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [-r concurrent-request-limit] [--recover] [-w ref] commit-id url");
1050 -#else
1041 usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] commit-id url");
1052 -#endif
1042 return 1;
1043 }
1044 commit_id = argv[arg];
@@ -1058,6 +1047,12 @@ int main(int argc, char **argv)
1047 curl_global_init(CURL_GLOBAL_ALL);
1048
1049 #ifdef USE_CURL_MULTI
1050 + char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
1051 + if (http_max_requests != NULL)
1052 + max_requests = atoi(http_max_requests);
1053 + if (max_requests < 1)
1054 + max_requests = DEFAULT_MAX_REQUESTS;
1055 +
1056 curlm = curl_multi_init();
1057 if (curlm == NULL) {
1058 fprintf(stderr, "Error creating curl multi handle.\n");