git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, junkio@cox.net
Subject: [PATCH 2/3] merge-recursive: refuse to merge binary files
Date: Tue, 5 Jun 2007 03:36:49 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0706050336270.4046@racer.site> (raw)


Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 merge-recursive.c          |    6 ++++++
 t/t6024-recursive-merge.sh |   14 ++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 4d70fd4..02c7983 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -658,6 +658,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
-- 
1.5.2.1.2626.ge1044-dirty

                 reply	other threads:[~2007-06-05  2:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0706050336270.4046@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).