Skip to content

Commit

Permalink
merge-recursive: refuse to merge binary files
Browse files Browse the repository at this point in the history
[jc: cherry-picked 9f30855 from 'master']

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 16, 2007
1 parent 634cd48 commit fadf488
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions t/t6024-recursive-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fadf488

Please sign in to comment.