From: Johannes Schindelin Date: Tue, 5 Jun 2007 02:37:13 +0000 (+0100) Subject: git-merge-file: refuse to merge binary files X-Git-Tag: v1.5.3-rc0~135^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5771907a5745799c559ff21ccfcabfd21cc23b36;p=git.git git-merge-file: refuse to merge binary files Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/builtin-merge-file.c b/builtin-merge-file.c index 913577390..10ec63b17 100644 --- a/builtin-merge-file.c +++ b/builtin-merge-file.c @@ -36,9 +36,13 @@ int cmd_merge_file(int argc, char **argv, char **envp) for (; i < 3; i++) names[i] = argv[i + 1]; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { if (read_mmfile(mmfs + i, argv[i + 1])) return -1; + if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size)) + return error("Cannot merge binary files: %s\n", + argv[i + 1]); + } ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2], &xpp, XDL_MERGE_ZEALOUS, &result); diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index c76fccfb5..1decbfba6 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -134,5 +134,10 @@ EOF test_expect_success "expected conflict markers" "git diff expect out" +test_expect_success 'binary files cannot be merged' ' + ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err && + grep "Cannot merge binary files" merge.err +' + test_done