git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-imap-send: use libcurl for implementation

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 10, 2014, 17:19 UTC
Message-ID
<xmqqfvdr9dob.fsf@gitster.dls.corp.google.com>
In-Reply-To
<545F8079.7010806@raz.or.at>
Bernhard Reiter <ockham@raz.or.at> writes:
Show 13 quoted lines
> Am 2014-11-09 um 14:00 schrieb Torsten Bögershausen:
>> On 2014-08-27 00.40, Bernhard Reiter wrote:
>>> Use libcurl's high-level API functions to implement git-imap-send
>>> instead of the previous low-level OpenSSL-based functions.
>>>
>> This doesn't seem to fully work under Debian 7:
>> /home/tb/projects/git/git.pu/imap-send.c:1546: undefined reference
>> to `curl_append_msgs_to_imap'
>
> Thx for the notice. I forgot to guard that with an #ifdef.
>
> The new patch below includes that, and the fix sent by Ramsay;
> hopefully the squashed/edited commit message is fine.
Queued with a small fix-ups, including
 - line-fold a couple of overlong lines;
 - avoid decl-after-stmt of "int prev_len";
 - reduce the scope of "struct struct auth" down to only the block
   it is used;
 - the footer of the log message now reads "helped-by ramsay", your
   sign-off and then mine.
Thanks.
diff --git a/imap-send.c b/imap-send.c
index 08271d9..4dfe4c2 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1349,7 +1349,8 @@ static void git_imap_config(void)
 	git_config_get_string("imap.authmethod", &server.auth_method);
 }
 
-static int append_msgs_to_imap(struct imap_server_conf *server, struct strbuf* all_msgs, int total)
+static int append_msgs_to_imap(struct imap_server_conf *server,
+			       struct strbuf* all_msgs, int total)
 {
 	struct strbuf msg = STRBUF_INIT;
 	struct imap_store *ctx = NULL;
@@ -1391,7 +1392,6 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 {
 	CURL *curl;
 	struct strbuf path = STRBUF_INIT;
-	struct strbuf auth = STRBUF_INIT;
 
 	if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
 		die("curl_global_init failed");
@@ -1414,11 +1414,12 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 	curl_easy_setopt(curl, CURLOPT_PORT, server.port);
 
 	if (server.auth_method) {
+		struct strbuf auth = STRBUF_INIT;
 		strbuf_addstr(&auth, "AUTH=");
 		strbuf_addstr(&auth, server.auth_method);
 		curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf);
+		strbuf_release(&auth);
 	}
-	strbuf_release(&auth);
 
 	if (server.use_ssl)
 		curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
@@ -1436,7 +1437,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 	return curl;
 }
 
-static int curl_append_msgs_to_imap(struct imap_server_conf *server, struct strbuf* all_msgs, int total) {
+static int curl_append_msgs_to_imap(struct imap_server_conf *server,
+				    struct strbuf* all_msgs, int total) {
 	int ofs = 0;
 	int n = 0;
 	struct buffer msgbuf = { STRBUF_INIT, 0 };
@@ -1449,17 +1451,19 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server, struct strb
 	fprintf(stderr, "sending %d message%s\n", total, (total != 1) ? "s" : "");
 	while (1) {
 		unsigned percent = n * 100 / total;
+		int prev_len;
 
 		fprintf(stderr, "%4u%% (%d/%d) done\r", percent, n, total);
 
-		int prev_len = msgbuf.buf.len;
+		prev_len = msgbuf.buf.len;
 		if (!split_msg(all_msgs, &msgbuf.buf, &ofs))
 			break;
 		if (server->use_html)
 			wrap_in_html(&msgbuf.buf);
 		lf_to_crlf(&msgbuf.buf);
 
-		curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)(msgbuf.buf.len-prev_len));
+		curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
+				 (curl_off_t)(msgbuf.buf.len-prev_len));
 
 		res = curl_easy_perform(curl);
 
Previous: Junio C Hamano
Message 12 of 12 in “git-imap-send: use libcurl for implementation”
  1. git-imap-send: use libcurl for implementationBernhard Reiter, Aug 26, 2014
  2. Junio C HamanoAug 27, 2014
  3. Bernhard ReiterOct 12, 2014
  4. Fwd: Re: [PATCH] git-imap-send: use libcurl for implementationBernhard Reiter, Oct 22, 2014
  5. Junio C HamanoOct 22, 2014
  6. git-imap-send: use libcurl for implementationBernhard Reiter, Oct 29, 2014
  7. Junio C HamanoOct 29, 2014
  8. Torsten BögershausenNov 9, 2014
  9. Bernhard ReiterNov 9, 2014
  10. Ramsay JonesNov 9, 2014
  11. Junio C HamanoNov 9, 2014
  12. Junio C HamanoNov 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.