Skip to content

Commit 308528a

Browse files
committed
Merge branch 'jk/union-merge-binary'
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
2 parents c3c0b71 + 382b601 commit 308528a

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

ll-merge.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
9191
* With -Xtheirs or -Xours, we have cleanly merged;
9292
* otherwise we got a conflict.
9393
*/
94-
return (opts->variant ? 0 : 1);
94+
return opts->variant == XDL_MERGE_FAVOR_OURS ||
95+
opts->variant == XDL_MERGE_FAVOR_THEIRS ?
96+
0 : 1;
9597
}
9698

9799
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,
136138

137139
static int ll_union_merge(const struct ll_merge_driver *drv_unused,
138140
mmbuffer_t *result,
139-
const char *path_unused,
141+
const char *path,
140142
mmfile_t *orig, const char *orig_name,
141143
mmfile_t *src1, const char *name1,
142144
mmfile_t *src2, const char *name2,
@@ -148,8 +150,8 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
148150
assert(opts);
149151
o = *opts;
150152
o.variant = XDL_MERGE_FAVOR_UNION;
151-
return ll_xdl_merge(drv_unused, result, path_unused,
152-
orig, NULL, src1, NULL, src2, NULL,
153+
return ll_xdl_merge(drv_unused, result, path,
154+
orig, orig_name, src1, name1, src2, name2,
153155
&o, marker_size);
154156
}
155157

t/t6406-merge-attr.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,22 @@ test_expect_success 'custom merge does not lock index' '
207207
git merge main
208208
'
209209

210+
test_expect_success 'binary files with union attribute' '
211+
git checkout -b bin-main &&
212+
printf "base\0" >bin.txt &&
213+
echo "bin.txt merge=union" >.gitattributes &&
214+
git add bin.txt .gitattributes &&
215+
git commit -m base &&
216+
217+
printf "one\0" >bin.txt &&
218+
git commit -am one &&
219+
220+
git checkout -b bin-side HEAD^ &&
221+
printf "two\0" >bin.txt &&
222+
git commit -am two &&
223+
224+
test_must_fail git merge bin-main 2>stderr &&
225+
grep -i "warning.*cannot merge.*HEAD vs. bin-main" stderr
226+
'
227+
210228
test_done

0 commit comments

Comments
 (0)