@matheusbsbs / matheus-bagliano / commits / 5771907a57
Fork 0

git-merge-file: refuse to merge binary files

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jun 5, 2007 at 03:37 UTC 5771907a5745799c559ff21ccfcabfd21cc23b36
2 files changed +10 -1
builtin-merge-file.c
+5 -1
@@ -36,9 +36,13 @@ int cmd_merge_file(int argc, char **argv, char **envp)
36 for (; i < 3; i++)
37 names[i] = argv[i + 1];
38
39 - for (i = 0; i < 3; i++)
39 + for (i = 0; i < 3; i++) {
40 if (read_mmfile(mmfs + i, argv[i + 1]))
41 return -1;
42 + if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
43 + return error("Cannot merge binary files: %s\n",
44 + argv[i + 1]);
45 + }
46
47 ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
48 &xpp, XDL_MERGE_ZEALOUS, &result);
t/t6023-merge-file.sh
+5
@@ -134,5 +134,10 @@ EOF
134
135 test_expect_success "expected conflict markers" "git diff expect out"
136
137 +test_expect_success 'binary files cannot be merged' '
138 + ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err &&
139 + grep "Cannot merge binary files" merge.err
140 +'
141 +
142 test_done
143