ident.c: add support for IPv6
[gitweb.git] / ll-merge.c
index fb61ea66a13eba3a8e91a05dbe1c37de98cec853..bf83290793059dc42d89db07a12e3bc3c14a48dc 100644 (file)
@@ -9,6 +9,7 @@
 #include "xdiff-interface.h"
 #include "run-command.h"
 #include "ll-merge.h"
+#include "quote.h"
 
 struct ll_merge_driver;
 
@@ -88,7 +89,10 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
        xmparam_t xmp;
        assert(opts);
 
-       if (buffer_is_binary(orig->ptr, orig->size) ||
+       if (orig->size > MAX_XDIFF_SIZE ||
+           src1->size > MAX_XDIFF_SIZE ||
+           src2->size > MAX_XDIFF_SIZE ||
+           buffer_is_binary(orig->ptr, orig->size) ||
            buffer_is_binary(src1->ptr, src1->size) ||
            buffer_is_binary(src2->ptr, src2->size)) {
                return ll_binary_merge(drv_unused, result,
@@ -166,17 +170,20 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 {
        char temp[4][50];
        struct strbuf cmd = STRBUF_INIT;
-       struct strbuf_expand_dict_entry dict[5];
+       struct strbuf_expand_dict_entry dict[6];
+       struct strbuf path_sq = STRBUF_INIT;
        const char *args[] = { NULL, NULL };
        int status, fd, i;
        struct stat st;
        assert(opts);
 
+       sq_quote_buf(&path_sq, path);
        dict[0].placeholder = "O"; dict[0].value = temp[0];
        dict[1].placeholder = "A"; dict[1].value = temp[1];
        dict[2].placeholder = "B"; dict[2].value = temp[2];
        dict[3].placeholder = "L"; dict[3].value = temp[3];
-       dict[4].placeholder = NULL; dict[4].value = NULL;
+       dict[4].placeholder = "P"; dict[4].value = path_sq.buf;
+       dict[5].placeholder = NULL; dict[5].value = NULL;
 
        if (fn->cmdline == NULL)
                die("custom merge driver %s lacks command line.", fn->name);
@@ -210,6 +217,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
        for (i = 0; i < 3; i++)
                unlink_or_warn(temp[i]);
        strbuf_release(&cmd);
+       strbuf_release(&path_sq);
        return status;
 }
 
@@ -225,11 +233,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
        const char *key, *name;
        int namelen;
 
-       if (!strcmp(var, "merge.default")) {
-               if (value)
-                       default_ll_merge = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "merge.default"))
+               return git_config_string(&default_ll_merge, var, value);
 
        /*
         * We are not interested in anything but "merge.<name>.variable";
@@ -254,12 +259,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
                ll_user_merge_tail = &(fn->next);
        }
 
-       if (!strcmp("name", key)) {
-               if (!value)
-                       return error("%s: lacks value", var);
-               fn->description = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp("name", key))
+               return git_config_string(&fn->description, var, value);
 
        if (!strcmp("driver", key)) {
                if (!value)
@@ -276,6 +277,7 @@ static int read_merge_config(const char *var, const char *value, void *cb)
                 *    %A - temporary file name for our version.
                 *    %B - temporary file name for the other branches' version.
                 *    %L - conflict marker length
+                *    %P - the original path (safely quoted for the shell)
                 *
                 * The external merge driver should write the results in the
                 * file named by %A, and signal that it has done with zero exit
@@ -285,12 +287,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
                return 0;
        }
 
-       if (!strcmp("recursive", key)) {
-               if (!value)
-                       return error("%s: lacks value", var);
-               fn->recursive = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp("recursive", key))
+               return git_config_string(&fn->recursive, var, value);
 
        return 0;
 }