]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ag/imap-send-resurrection' into next
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Jun 2025 16:49:01 +0000 (09:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Jun 2025 16:49:01 +0000 (09:49 -0700)
"git imap-send" has been broken for a long time, which has been
resurrected and then taught to talk OAuth2.0 etc.

* ag/imap-send-resurrection:
  imap-send: fix minor mistakes in the logs
  imap-send: display the destination mailbox when sending a message
  imap-send: display port alongwith host when git credential is invoked
  imap-send: add ability to list the available folders
  imap-send: enable specifying the folder using the command line
  imap-send: add PLAIN authentication method to OpenSSL
  imap-send: add support for OAuth2.0 authentication
  imap-send: gracefully fail if CRAM-MD5 authentication is requested without OpenSSL
  imap-send: fix memory leak in case auth_cram_md5 fails
  imap-send: fix bug causing cfg->folder being set to NULL

1  2 
imap-send.c

diff --cc imap-send.c
index 2e812f5a6e9e10d187507fa4458606bd5867680a,8f4801dc074341429cbf213c8fad5c7348b20124..603e3d6fbc429d0753d11624d1565693e8b9417f
@@@ -1420,26 -1642,33 +1642,33 @@@ static CURL *setup_curl(struct imap_ser
  
        curl_easy_setopt(curl, CURLOPT_URL, path.buf);
        strbuf_release(&path);
 -      curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);
 +      curl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);
  
        if (srvc->auth_method) {
-               struct strbuf auth = STRBUF_INIT;
-               strbuf_addstr(&auth, "AUTH=");
-               strbuf_addstr(&auth, srvc->auth_method);
-               curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf);
-               strbuf_release(&auth);
+               if (!strcmp(srvc->auth_method, "XOAUTH2") ||
+                   !strcmp(srvc->auth_method, "OAUTHBEARER")) {
+                       /*
+                        * While CURLOPT_XOAUTH2_BEARER looks as if it only supports XOAUTH2,
+                        * upon debugging, it has been found that it is capable of detecting
+                        * the best option out of OAUTHBEARER and XOAUTH2.
+                        */
+                       curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, srvc->pass);
+               } else {
+                       struct strbuf auth = STRBUF_INIT;
+                       strbuf_addstr(&auth, "AUTH=");
+                       strbuf_addstr(&auth, srvc->auth_method);
+                       curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf);
+                       strbuf_release(&auth);
+               }
        }
  
        if (!srvc->use_ssl)
                curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
  
 -      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);
 -      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);
 +      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);
 +      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);
  
-       curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
-       curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
        if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
                http_trace_curl_no_data();
        setup_curl_trace(curl);