summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-06-17 02:26:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-17 02:26:20 (GMT)
commitcf9b0c4f1cb05f4c49240766b68856b3b57b2ee3 (patch)
treefa359a83a31bf959a7e6f971104b2606064dcbc1
parent4c634a4a8ffae654c3cc4e403aa31e7d660d7e6d (diff)
parent382b601acde12b298bb84faa11b3f42868716a0d (diff)
downloadgit-cf9b0c4f1cb05f4c49240766b68856b3b57b2ee3.zip
git-cf9b0c4f1cb05f4c49240766b68856b3b57b2ee3.tar.gz
git-cf9b0c4f1cb05f4c49240766b68856b3b57b2ee3.tar.bz2
Merge branch 'jk/union-merge-binary' into jch
The "union" conflict resultion 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
-rw-r--r--ll-merge.c10
-rwxr-xr-xt/t6406-merge-attr.sh18
2 files changed, 24 insertions, 4 deletions
diff --git a/ll-merge.c b/ll-merge.c
index 9a8a2c3..2616575 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -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);
}
diff --git a/t/t6406-merge-attr.sh b/t/t6406-merge-attr.sh
index d5a4ac2..8494645 100755
--- a/t/t6406-merge-attr.sh
+++ b/t/t6406-merge-attr.sh
@@ -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