summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-06-05 02:36:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-06-05 06:07:19 (GMT)
commit9f30855d0ff5206e85e45f0307be9d18ffda41d3 (patch)
treee30410dbde5863a683dcaea3d70689dd141f5afa
parent6bfce93e04d13ecb42008a3cf214cc892f480f0c (diff)
downloadgit-9f30855d0ff5206e85e45f0307be9d18ffda41d3.zip
git-9f30855d0ff5206e85e45f0307be9d18ffda41d3.tar.gz
git-9f30855d0ff5206e85e45f0307be9d18ffda41d3.tar.bz2
merge-recursive: refuse to merge binary files
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--merge-recursive.c6
-rwxr-xr-xt/t6024-recursive-merge.sh14
2 files changed, 20 insertions, 0 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 8f72b2c..4a82b74 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -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,
diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index a398556..058db9c 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -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