Merge branch 'ye/http-accept-language'
authorJunio C Hamano <gitster@pobox.com>
Fri, 6 Mar 2015 23:02:24 +0000 (15:02 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Mar 2015 23:02:25 +0000 (15:02 -0800)
Compilation fix for a recent topic in 'master'.

* ye/http-accept-language:
gettext.c: move get_preferred_languages() from http.c

1  2 
gettext.h
http.c
diff --combined gettext.h
index dc1722dd4bc6b1aa7d998cb055a40000c05a0b5e,e539482ae798d3c781c9d56cddd9f048d6b1badc..33696a40b8a11262d090a2eec4dfdce0fed6af0f
+++ b/gettext.h
@@@ -63,30 -63,8 +63,32 @@@ const char *Q_(const char *msgid, cons
  }
  
  /* Mark msgid for translation but do not translate it. */
 +#if !USE_PARENS_AROUND_GETTEXT_N
  #define N_(msgid) msgid
 +#else
 +/*
 + * Strictly speaking, this will lead to invalid C when
 + * used this way:
 + *    static const char s[] = N_("FOO");
 + * which will expand to
 + *    static const char s[] = ("FOO");
 + * and in valid C, the initializer on the right hand side must
 + * be without the parentheses.  But many compilers do accept it
 + * as a language extension and it will allow us to catch mistakes
 + * like:
 + *    static const char *msgs[] = {
 + *            N_("one")
 + *            N_("two"),
 + *            N_("three"),
 + *            NULL
 + *    };
 + * (notice the missing comma on one of the lines) by forcing
 + * a compilation error, because parenthesised ("one") ("two")
 + * will not get silently turned into ("onetwo").
 + */
 +#define N_(msgid) (msgid)
 +#endif
  
+ const char *get_preferred_languages(void);
  #endif
diff --combined http.c
index 0153fb0b626d1fc28eba1bece2406b64fcaa0ecb,007b29b8bb4cf27b619467d69a88ef5c79db282d..9c825afefdda70b8f8ccda0b9ed06e5d54333a50
--- 1/http.c
--- 2/http.c
+++ b/http.c
@@@ -8,6 -8,7 +8,7 @@@
  #include "credential.h"
  #include "version.h"
  #include "pkt-line.h"
+ #include "gettext.h"
  
  int active_requests;
  int http_is_verbose;
@@@ -62,9 -63,6 +63,9 @@@ static const char *user_agent
  
  static struct credential cert_auth = CREDENTIAL_INIT;
  static int ssl_cert_password_required;
 +#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
 +static unsigned long http_auth_methods = CURLAUTH_ANY;
 +#endif
  
  static struct curl_slist *pragma_header;
  static struct curl_slist *no_pragma_header;
@@@ -119,37 -117,6 +120,37 @@@ size_t fwrite_null(char *ptr, size_t el
        return eltsize * nmemb;
  }
  
 +static void closedown_active_slot(struct active_request_slot *slot)
 +{
 +      active_requests--;
 +      slot->in_use = 0;
 +}
 +
 +static void finish_active_slot(struct active_request_slot *slot)
 +{
 +      closedown_active_slot(slot);
 +      curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
 +
 +      if (slot->finished != NULL)
 +              (*slot->finished) = 1;
 +
 +      /* Store slot results so they can be read after the slot is reused */
 +      if (slot->results != NULL) {
 +              slot->results->curl_result = slot->curl_result;
 +              slot->results->http_code = slot->http_code;
 +#if LIBCURL_VERSION_NUM >= 0x070a08
 +              curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
 +                                &slot->results->auth_avail);
 +#else
 +              slot->results->auth_avail = 0;
 +#endif
 +      }
 +
 +      /* Run callback if appropriate */
 +      if (slot->callback_func != NULL)
 +              slot->callback_func(slot->callback_data);
 +}
 +
  #ifdef USE_CURL_MULTI
  static void process_curl_messages(void)
  {
@@@ -405,9 -372,7 +406,9 @@@ static CURL *get_curl_handle(void
  
        if (curl_http_proxy) {
                curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
 +#if LIBCURL_VERSION_NUM >= 0x070a07
                curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
 +#endif
        }
  
        set_curl_keepalive(result);
@@@ -621,9 -586,6 +622,9 @@@ struct active_request_slot *get_active_
        curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
        curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
        curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
 +#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
 +      curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
 +#endif
        if (http_auth.password)
                init_curl_http_auth(slot->curl);
  
@@@ -774,6 -736,12 +775,6 @@@ void run_active_slot(struct active_requ
  #endif
  }
  
 -static void closedown_active_slot(struct active_request_slot *slot)
 -{
 -      active_requests--;
 -      slot->in_use = 0;
 -}
 -
  static void release_active_slot(struct active_request_slot *slot)
  {
        closedown_active_slot(slot);
  #endif
  }
  
 -void finish_active_slot(struct active_request_slot *slot)
 -{
 -      closedown_active_slot(slot);
 -      curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
 -
 -      if (slot->finished != NULL)
 -              (*slot->finished) = 1;
 -
 -      /* Store slot results so they can be read after the slot is reused */
 -      if (slot->results != NULL) {
 -              slot->results->curl_result = slot->curl_result;
 -              slot->results->http_code = slot->http_code;
 -#if LIBCURL_VERSION_NUM >= 0x070a08
 -              curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
 -                                &slot->results->auth_avail);
 -#else
 -              slot->results->auth_avail = 0;
 -#endif
 -      }
 -
 -      /* Run callback if appropriate */
 -      if (slot->callback_func != NULL)
 -              slot->callback_func(slot->callback_data);
 -}
 -
  void finish_all_active_slots(void)
  {
        struct active_request_slot *slot = active_queue_head;
@@@ -852,7 -845,7 +853,7 @@@ char *get_remote_object_url(const char 
        return strbuf_detach(&buf, NULL);
  }
  
 -int handle_curl_result(struct slot_results *results)
 +static int handle_curl_result(struct slot_results *results)
  {
        /*
         * If we see a failing http code with CURLE_OK, we have turned off
                        credential_reject(&http_auth);
                        return HTTP_NOAUTH;
                } else {
 +#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
 +                      http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
 +#endif
                        return HTTP_REAUTH;
                }
        } else {
@@@ -1002,32 -992,6 +1003,6 @@@ static void extract_content_type(struc
                strbuf_addstr(charset, "ISO-8859-1");
  }
  
- /*
-  * Guess the user's preferred languages from the value in LANGUAGE environment
-  * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
-  *
-  * The result can be a colon-separated list like "ko:ja:en".
-  */
- static const char *get_preferred_languages(void)
- {
-       const char *retval;
-       retval = getenv("LANGUAGE");
-       if (retval && *retval)
-               return retval;
- #ifndef NO_GETTEXT
-       retval = setlocale(LC_MESSAGES, NULL);
-       if (retval && *retval &&
-               strcmp(retval, "C") &&
-               strcmp(retval, "POSIX"))
-               return retval;
- #endif
-       return NULL;
- }
  static void write_accept_language(struct strbuf *buf)
  {
        /*
@@@ -1399,7 -1363,7 +1374,7 @@@ static int fetch_and_setup_pack_index(s
        int ret;
  
        if (has_pack_index(sha1)) {
 -              new_pack = parse_pack_index(sha1, NULL);
 +              new_pack = parse_pack_index(sha1, sha1_pack_index_name(sha1));
                if (!new_pack)
                        return -1; /* parse_pack_index() already issued error message */
                goto add_pack;