{"thread":{"id":"997","subject":"[PATCH] Add more curl options to git-http-pull","startedAt":"2005-06-20T23:48:31Z","lastAt":"2005-06-20T23:48:31Z","messageCount":1,"participants":["Darrin Thompson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5095","messageId":"1119311311.3926.26.camel@localhost.localdomain","threadId":"997","inReplyTo":null,"subject":"[PATCH] Add more curl options to git-http-pull","fromName":"Darrin Thompson","fromEmail":"darrint@progeny.com","sentAt":"2005-06-20T23:48:31Z","receivedAt":"2005-06-20T23:48:31Z","isPatch":true,"sender":{"key":"darrint@progeny.com","avatar":null},"body":"All,\n\nThis patch makes git-http-pull work with basic http auth and ssl when\nyou aren't using a real cert.\n\nAlso, it makes curl's verbose output available, which is useful for\ndebugging.\n\nApologies as I expect my mail client is munging this patch slightly.\n\nSigned-off-by: Darrin Thompson <darrint at progeny com>\n---\n\nCreate option to turn off ssl peer verification.\nCreate option to provide username:password to curl.\nMake -v additive.\nWhen -v is specified twice, turn on CURLOPT_VERBOSE.\n\ndiff --git a/http-pull.c b/http-pull.c\n--- a/http-pull.c\n+++ b/http-pull.c\n@@ -15,6 +15,8 @@ static z_stream stream;\n\n static int local;\n static int zret;\n+static int curl_ssl_verify_enabled = 1;\n+static char *curl_user_pwd = NULL;\n\n static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n                               void *data) {\n@@ -117,12 +119,17 @@ int main(int argc, char **argv)\n                        get_tree = 1;\n                        get_history = 1;\n                } else if (argv[arg][1] == 'v') {\n-                       get_verbosely = 1;\n+                       get_verbosely += 1;\n+               } else if (argv[arg][1] == 'S') {\n+                        curl_ssl_verify_enabled = 0;\n+               } else if (argv[arg][1] == 'u') {\n+                        arg++;\n+                        curl_user_pwd = argv[arg];\n                }\n                arg++;\n        }\n        if (argc < arg + 2) {\n-               usage(\"git-http-pull [-c] [-t] [-a] [-d] [-v]\n[--recover] commit-id url\");\n+               usage(\"git-http-pull [-u] user:passwd [-S] [-c] [-t]\n[-a] [-d] [-v] [--recover] commit-id url\");\n                return 1;\n        }\n        commit_id = argv[arg];\n@@ -131,6 +138,13 @@ int main(int argc, char **argv)\n        curl_global_init(CURL_GLOBAL_ALL);\n\n        curl = curl_easy_init();\n+        if (curl_user_pwd) {\n+                curl_easy_setopt(curl, CURLOPT_USERPWD, curl_user_pwd);\n+        }\n+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER,\ncurl_ssl_verify_enabled);\n+        if (get_verbosely >= 2) {\n+                curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);\n+        }\n\n        base = url;\n\n\n\n"}]}