Skip to content

Commit

Permalink
git-merge-file: refuse to merge binary files
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 5, 2007
1 parent 9f30855 commit 5771907
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builtin-merge-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions t/t6023-merge-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5771907

Please sign in to comment.