Allow the test suite to pass in a directory whose name contains spaces
[gitweb.git] / ll-merge.c
index ff4a43a982a6a67ec826fdb01153a9e35e720751..ac0d4a5d78d956f09aa0082b286babc36f04b593 100644 (file)
@@ -47,7 +47,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
        assert(opts);
 
        /*
-        * The tentative merge result is the or common ancestor for an internal merge.
+        * The tentative merge result is the common ancestor for an
+        * internal merge.  For the final merge, it is "ours" by
+        * default but -Xours/-Xtheirs can tweak the choice.
         */
        if (opts->virtual_ancestor) {
                stolen = orig;
@@ -334,15 +336,6 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
        return &ll_merge_drv[LL_TEXT_MERGE];
 }
 
-static int git_path_check_merge(const char *path, struct git_attr_check check[2])
-{
-       if (!check[0].attr) {
-               check[0].attr = git_attr("merge");
-               check[1].attr = git_attr("conflict-marker-size");
-       }
-       return git_check_attr(path, 2, check);
-}
-
 static void normalize_file(mmfile_t *mm, const char *path)
 {
        struct strbuf strbuf = STRBUF_INIT;
@@ -360,7 +353,7 @@ int ll_merge(mmbuffer_t *result_buf,
             mmfile_t *theirs, const char *their_label,
             const struct ll_merge_options *opts)
 {
-       static struct git_attr_check check[2];
+       static struct attr_check *check;
        static const struct ll_merge_options default_opts;
        const char *ll_driver_name = NULL;
        int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
@@ -374,17 +367,25 @@ int ll_merge(mmbuffer_t *result_buf,
                normalize_file(ours, path);
                normalize_file(theirs, path);
        }
-       if (!git_path_check_merge(path, check)) {
-               ll_driver_name = check[0].value;
-               if (check[1].value) {
-                       marker_size = atoi(check[1].value);
+
+       if (!check)
+               check = attr_check_initl("merge", "conflict-marker-size", NULL);
+
+       if (!git_check_attr(path, check)) {
+               ll_driver_name = check->items[0].value;
+               if (check->items[1].value) {
+                       marker_size = atoi(check->items[1].value);
                        if (marker_size <= 0)
                                marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
                }
        }
        driver = find_ll_merge_driver(ll_driver_name);
-       if (opts->virtual_ancestor && driver->recursive)
-               driver = find_ll_merge_driver(driver->recursive);
+
+       if (opts->virtual_ancestor) {
+               if (driver->recursive)
+                       driver = find_ll_merge_driver(driver->recursive);
+               marker_size += 2;
+       }
        return driver->fn(driver, result_buf, path, ancestor, ancestor_label,
                          ours, our_label, theirs, their_label,
                          opts, marker_size);
@@ -392,13 +393,13 @@ int ll_merge(mmbuffer_t *result_buf,
 
 int ll_merge_marker_size(const char *path)
 {
-       static struct git_attr_check check;
+       static struct attr_check *check;
        int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
 
-       if (!check.attr)
-               check.attr = git_attr("conflict-marker-size");
-       if (!git_check_attr(path, 1, &check) && check.value) {
-               marker_size = atoi(check.value);
+       if (!check)
+               check = attr_check_initl("conflict-marker-size", NULL);
+       if (!git_check_attr(path, check) && check->items[0].value) {
+               marker_size = atoi(check->items[0].value);
                if (marker_size <= 0)
                        marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
        }