Skip to content

Commit

Permalink
Teach --text option to diff
Browse files Browse the repository at this point in the history
Add new item text to struct diff_options.
If set then do not try to detect binary files.

Signed-off-by: Stephan Feder <sf@b-i-t.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Stephan Feder authored and Junio C Hamano committed Jul 7, 2006
1 parent 6bdca89 commit 6d64ea9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static void builtin_diff(const char *name_a,
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");

if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) {
if (!o->text && (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2))) {
/* Quite common confusing case */
if (mf1.size == mf2.size &&
!memcmp(mf1.ptr, mf2.ptr, mf1.size))
Expand Down Expand Up @@ -1561,6 +1561,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->output_format |= DIFF_FORMAT_PATCH;
options->full_index = options->binary = 1;
}
else if (!strcmp(arg, "--text")) {
options->text = 1;
}
else if (!strcmp(arg, "--name-only"))
options->output_format |= DIFF_FORMAT_NAME;
else if (!strcmp(arg, "--name-status"))
Expand Down
1 change: 1 addition & 0 deletions diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct diff_options {
unsigned recursive:1,
tree_in_recursive:1,
binary:1,
text:1,
full_index:1,
silent_on_remove:1,
find_copies_harder:1,
Expand Down

0 comments on commit 6d64ea9

Please sign in to comment.