提交 fadf488f 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

merge-recursive: refuse to merge binary files

[jc: cherry-picked 9f30855d from 'master']
Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 634cd48a
......@@ -680,6 +680,12 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
{
xpparam_t xpp;
if (buffer_is_binary(orig->ptr, orig->size) ||
buffer_is_binary(src1->ptr, src1->size) ||
buffer_is_binary(src2->ptr, src2->size))
return error("Cannot merge binary files: %s vs. %s\n",
name1, name2);
memset(&xpp, 0, sizeof(xpp));
return xdl_merge(orig,
src1, name1,
......
......@@ -81,4 +81,18 @@ EOF
test_expect_success "virtual trees were processed" "git diff expect out"
git reset --hard
test_expect_success 'refuse to merge binary files' '
printf "\0" > binary-file &&
git add binary-file &&
git commit -m binary &&
git checkout G &&
printf "\0\0" > binary-file &&
git add binary-file &&
git commit -m binary2 &&
! git merge F > merge.out 2> merge.err &&
grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
merge.err
'
test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册