Skip to content

Commit 89dd19e

Browse files
committed
Merge branch 'js/merge'
* js/merge: git-merge-file: refuse to merge binary files
2 parents 6668833 + 5771907 commit 89dd19e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin-merge-file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ int cmd_merge_file(int argc, char **argv, char **envp)
3636
for (; i < 3; i++)
3737
names[i] = argv[i + 1];
3838

39-
for (i = 0; i < 3; i++)
39+
for (i = 0; i < 3; i++) {
4040
if (read_mmfile(mmfs + i, argv[i + 1]))
4141
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+
}
4246

4347
ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
4448
&xpp, XDL_MERGE_ZEALOUS, &result);

t/t6023-merge-file.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,9 @@ EOF
134134

135135
test_expect_success "expected conflict markers" "git diff expect out"
136136

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+
137142
test_done

0 commit comments

Comments
 (0)