lstat_cache(): print a warning if doing ping-pong between cache types
[gitweb.git] / ll-merge.c
index 5ae74331bc2c55638bc5bf1bbfdc7e340199cb01..fa2ca5250c75a0d335570a3a3c71b20ebd0b42fa 100644 (file)
@@ -8,7 +8,6 @@
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
-#include "interpolate.h"
 #include "ll-merge.h"
 
 struct ll_merge_driver;
@@ -63,6 +62,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
                        int virtual_ancestor)
 {
        xpparam_t xpp;
+       int style = 0;
 
        if (buffer_is_binary(orig->ptr, orig->size) ||
            buffer_is_binary(src1->ptr, src1->size) ||
@@ -77,10 +77,12 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
        }
 
        memset(&xpp, 0, sizeof(xpp));
+       if (git_xmerge_style >= 0)
+               style = git_xmerge_style;
        return xdl_merge(orig,
                         src1, name1,
                         src2, name2,
-                        &xpp, XDL_MERGE_ZEALOUS,
+                        &xpp, XDL_MERGE_ZEALOUS | style,
                         result);
 }
 
@@ -95,10 +97,15 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
        char *src, *dst;
        long size;
        const int marker_size = 7;
-
-       int status = ll_xdl_merge(drv_unused, result, path_unused,
-                                 orig, src1, NULL, src2, NULL,
-                                 virtual_ancestor);
+       int status, saved_style;
+
+       /* We have to force the RCS "merge" style */
+       saved_style = git_xmerge_style;
+       git_xmerge_style = 0;
+       status = ll_xdl_merge(drv_unused, result, path_unused,
+                             orig, src1, NULL, src2, NULL,
+                             virtual_ancestor);
+       git_xmerge_style = saved_style;
        if (status <= 0)
                return status;
        size = result->size;
@@ -161,11 +168,12 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
                        int virtual_ancestor)
 {
        char temp[3][50];
-       char cmdbuf[2048];
-       struct interp table[] = {
-               { "%O" },
-               { "%A" },
-               { "%B" },
+       struct strbuf cmd = STRBUF_INIT;
+       struct strbuf_expand_dict_entry dict[] = {
+               { "O", temp[0] },
+               { "A", temp[1] },
+               { "B", temp[2] },
+               { NULL }
        };
        struct child_process child;
        const char *args[20];
@@ -181,17 +189,13 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
        create_temp(src1, temp[1]);
        create_temp(src2, temp[2]);
 
-       interp_set_entry(table, 0, temp[0]);
-       interp_set_entry(table, 1, temp[1]);
-       interp_set_entry(table, 2, temp[2]);
-
-       interpolate(cmdbuf, sizeof(cmdbuf), fn->cmdline, table, 3);
+       strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
 
        memset(&child, 0, sizeof(child));
        child.argv = args;
        args[0] = "sh";
        args[1] = "-c";
-       args[2] = cmdbuf;
+       args[2] = cmd.buf;
        args[3] = NULL;
 
        status = run_command(&child);
@@ -216,6 +220,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
  bad:
        for (i = 0; i < 3; i++)
                unlink(temp[i]);
+       strbuf_release(&cmd);
        return status;
 }
 
@@ -225,7 +230,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 static struct ll_merge_driver *ll_user_merge, **ll_user_merge_tail;
 static const char *default_ll_merge;
 
-static int read_merge_config(const char *var, const char *value)
+static int read_merge_config(const char *var, const char *value, void *cb)
 {
        struct ll_merge_driver *fn;
        const char *ep, *name;
@@ -309,7 +314,7 @@ static void initialize_ll_merge(void)
        if (ll_user_merge_tail)
                return;
        ll_user_merge_tail = &ll_user_merge;
-       git_config(read_merge_config);
+       git_config(read_merge_config, NULL);
 }
 
 static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr)