]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/union-merge-binary'
authorJunio C Hamano <gitster@pobox.com>
Tue, 13 Jul 2021 23:52:51 +0000 (16:52 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Jul 2021 23:52:51 +0000 (16:52 -0700)
The "union" conflict resolution variant misbehaved when used with
binary merge driver.

* jk/union-merge-binary:
  ll_union_merge(): rename path_unused parameter
  ll_union_merge(): pass name labels to ll_xdl_merge()
  ll_binary_merge(): handle XDL_MERGE_FAVOR_UNION

ll-merge.c
t/t6406-merge-attr.sh

index 9a8a2c365c7a33fbf1fb4b1a50505ea19fe5558d..261657578c756c94f27ba03392ef82f4173d5460 100644 (file)
@@ -91,7 +91,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
         * With -Xtheirs or -Xours, we have cleanly merged;
         * otherwise we got a conflict.
         */
-       return (opts->variant ? 0 : 1);
+       return opts->variant == XDL_MERGE_FAVOR_OURS ||
+              opts->variant == XDL_MERGE_FAVOR_THEIRS ?
+              0 : 1;
 }
 
 static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
@@ -136,7 +138,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 
 static int ll_union_merge(const struct ll_merge_driver *drv_unused,
                          mmbuffer_t *result,
-                         const char *path_unused,
+                         const char *path,
                          mmfile_t *orig, const char *orig_name,
                          mmfile_t *src1, const char *name1,
                          mmfile_t *src2, const char *name2,
@@ -148,8 +150,8 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
        assert(opts);
        o = *opts;
        o.variant = XDL_MERGE_FAVOR_UNION;
-       return ll_xdl_merge(drv_unused, result, path_unused,
-                           orig, NULL, src1, NULL, src2, NULL,
+       return ll_xdl_merge(drv_unused, result, path,
+                           orig, orig_name, src1, name1, src2, name2,
                            &o, marker_size);
 }
 
index d5a4ac2d81cd708057aa4abab0267ccccc1bb6e8..849464583713c40859d2473d2a4075367b1e4c09 100755 (executable)
@@ -207,4 +207,22 @@ test_expect_success 'custom merge does not lock index' '
        git merge main
 '
 
+test_expect_success 'binary files with union attribute' '
+       git checkout -b bin-main &&
+       printf "base\0" >bin.txt &&
+       echo "bin.txt merge=union" >.gitattributes &&
+       git add bin.txt .gitattributes &&
+       git commit -m base &&
+
+       printf "one\0" >bin.txt &&
+       git commit -am one &&
+
+       git checkout -b bin-side HEAD^ &&
+       printf "two\0" >bin.txt &&
+       git commit -am two &&
+
+       test_must_fail git merge bin-main 2>stderr &&
+       grep -i "warning.*cannot merge.*HEAD vs. bin-main" stderr
+'
+
 test_done