Merge branch 'ak/curl-imap-send-explicit-scheme' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:13 +0000 (09:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:13 +0000 (09:01 -0700)
When we started cURL to talk to imap server when a new enough
version of cURL library is available, we forgot to explicitly add
imap(s):// before the destination. To some folks, that didn't work
and the library tried to make HTTP(s) requests instead.

* ak/curl-imap-send-explicit-scheme:
imap-send: Tell cURL to use imap:// or imaps://

1  2 
imap-send.c
diff --combined imap-send.c
index 0f5f4760e90de236757924683478c7f25cdb653f,7dd5acf9a97a3e37be28fe5bcbd7b76b3030fa01..adb9738c308f70190f6c3996d5781e6fbc4dea3f
@@@ -511,7 -511,7 +511,7 @@@ static int nfsnprintf(char *buf, int bl
  
        va_start(va, fmt);
        if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)
 -              die("Fatal: buffer too small. Please report a bug.");
 +              die("BUG: buffer too small. Please report a bug.");
        va_end(va);
        return ret;
  }
@@@ -1410,6 -1410,7 +1410,7 @@@ static CURL *setup_curl(struct imap_ser
        curl_easy_setopt(curl, CURLOPT_USERNAME, server.user);
        curl_easy_setopt(curl, CURLOPT_PASSWORD, server.pass);
  
+       strbuf_addstr(&path, server.use_ssl ? "imaps://" : "imap://");
        strbuf_addstr(&path, server.host);
        if (!path.len || path.buf[path.len - 1] != '/')
                strbuf_addch(&path, '/');
  
        if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
                curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 +      setup_curl_trace(curl);
  
        return curl;
  }
@@@ -1495,12 -1495,16 +1496,12 @@@ static int curl_append_msgs_to_imap(str
  }
  #endif
  
 -int main(int argc, char **argv)
 +int cmd_main(int argc, const char **argv)
  {
        struct strbuf all_msgs = STRBUF_INIT;
        int total;
        int nongit_ok;
  
 -      git_extract_argv0_path(argv[0]);
 -
 -      git_setup_gettext();
 -
        setup_git_directory_gently(&nongit_ok);
        git_imap_config();