Merge branch 'da/include-compat-util-first-in-c'
authorJunio C Hamano <gitster@pobox.com>
Tue, 14 Oct 2014 17:49:00 +0000 (10:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Oct 2014 17:49:01 +0000 (10:49 -0700)
Code clean-up.

* da/include-compat-util-first-in-c:
cleanups: ensure that git-compat-util.h is included first

1  2 
http.c
merge-recursive.c
diff --combined http.c
index 0adcec4683f997044807a772713d476dd77cf105,c0663cd41f3406c8b43ae562a575b2bd5c283801..040f362a6a299618288c9249588ceb7aed6f3011
--- 1/http.c
--- 2/http.c
+++ b/http.c
@@@ -1,3 -1,4 +1,4 @@@
+ #include "git-compat-util.h"
  #include "http.h"
  #include "pack.h"
  #include "sideband.h"
@@@ -300,9 -301,6 +301,9 @@@ static CURL *get_curl_handle(void
  {
        CURL *result = curl_easy_init();
  
 +      if (!result)
 +              die("curl_easy_init failed");
 +
        if (!curl_ssl_verify) {
                curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
                curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);
@@@ -402,8 -400,7 +403,8 @@@ void http_init(struct remote *remote, c
        git_config(urlmatch_config_entry, &config);
        free(normalized_url);
  
 -      curl_global_init(CURL_GLOBAL_ALL);
 +      if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
 +              die("curl_global_init failed");
  
        http_proactive_auth = proactive_auth;
  
        }
  
        curlm = curl_multi_init();
 -      if (curlm == NULL) {
 -              fprintf(stderr, "Error creating curl multi handle.\n");
 -              exit(1);
 -      }
 +      if (!curlm)
 +              die("curl_multi_init failed");
  #endif
  
        if (getenv("GIT_SSL_NO_VERIFY"))
@@@ -1334,7 -1333,7 +1335,7 @@@ int finish_http_pack_request(struct htt
        struct packed_git **lst;
        struct packed_git *p = preq->target;
        char *tmp_idx;
 -      struct child_process ip;
 +      struct child_process ip = CHILD_PROCESS_INIT;
        const char *ip_argv[8];
  
        close_pack_index(p);
        ip_argv[3] = preq->tmpfile;
        ip_argv[4] = NULL;
  
 -      memset(&ip, 0, sizeof(ip));
        ip.argv = ip_argv;
        ip.git_cmd = 1;
        ip.no_stdin = 1;
diff --combined merge-recursive.c
index 8ad4be897d88c691d43c30afb698a1ae952b8596,b55a0056e4770d510d81df84cfd7bcb949996016..9fc71a2391bff6c718cab39865371d2b43bf15a0
@@@ -3,8 -3,8 +3,8 @@@
   * Fredrik Kuivinen.
   * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
   */
- #include "advice.h"
  #include "cache.h"
+ #include "advice.h"
  #include "cache-tree.h"
  #include "commit.h"
  #include "blob.h"
@@@ -163,7 -163,9 +163,7 @@@ static void output(struct merge_option
        if (!show(o, v))
                return;
  
 -      strbuf_grow(&o->obuf, o->call_depth * 2 + 2);
 -      memset(o->obuf.buf + o->obuf.len, ' ', o->call_depth * 2);
 -      strbuf_setlen(&o->obuf, o->obuf.len + o->call_depth * 2);
 +      strbuf_addchars(&o->obuf, ' ', o->call_depth * 2);
  
        va_start(ap, fmt);
        strbuf_vaddf(&o->obuf, fmt, ap);
@@@ -1555,7 -1557,7 +1555,7 @@@ static int blob_unchanged(const unsigne
         * unchanged since their sha1s have already been compared.
         */
        if (renormalize_buffer(path, o.buf, o.len, &o) |
 -          renormalize_buffer(path, a.buf, o.len, &a))
 +          renormalize_buffer(path, a.buf, a.len, &a))
                ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
  
  error_return:
@@@ -1686,6 -1688,10 +1686,6 @@@ static int merge_content(struct merge_o
  static int process_entry(struct merge_options *o,
                         const char *path, struct stage_data *entry)
  {
 -      /*
 -      printf("processing entry, clean cache: %s\n", index_only ? "yes": "no");
 -      print_index_entry("\tpath: ", entry);
 -      */
        int clean_merge = 1;
        int normalize = o->renormalize;
        unsigned o_mode = entry->stages[1].mode;
@@@ -2020,12 -2026,22 +2020,12 @@@ int merge_recursive_generic(struct merg
        return clean ? 0 : 1;
  }
  
 -static int merge_recursive_config(const char *var, const char *value, void *cb)
 +static void merge_recursive_config(struct merge_options *o)
  {
 -      struct merge_options *o = cb;
 -      if (!strcmp(var, "merge.verbosity")) {
 -              o->verbosity = git_config_int(var, value);
 -              return 0;
 -      }
 -      if (!strcmp(var, "diff.renamelimit")) {
 -              o->diff_rename_limit = git_config_int(var, value);
 -              return 0;
 -      }
 -      if (!strcmp(var, "merge.renamelimit")) {
 -              o->merge_rename_limit = git_config_int(var, value);
 -              return 0;
 -      }
 -      return git_xmerge_config(var, value, cb);
 +      git_config_get_int("merge.verbosity", &o->verbosity);
 +      git_config_get_int("diff.renamelimit", &o->diff_rename_limit);
 +      git_config_get_int("merge.renamelimit", &o->merge_rename_limit);
 +      git_config(git_xmerge_config, NULL);
  }
  
  void init_merge_options(struct merge_options *o)
        o->diff_rename_limit = -1;
        o->merge_rename_limit = -1;
        o->renormalize = 0;
 -      git_config(merge_recursive_config, o);
 +      merge_recursive_config(o);
        if (getenv("GIT_MERGE_VERBOSITY"))
                o->verbosity =
                        strtol(getenv("GIT_MERGE_VERBOSITY"), NULL, 10);