Skip to content

Commit 88f0d5d

Browse files
author
Junio C Hamano
committed
Merge branch 'sf/diff'
2 parents f3aafa4 + d507bb1 commit 88f0d5d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Documentation/diff-options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,11 @@
9494
Swap two inputs; that is, show differences from index or
9595
on-disk file to tree contents.
9696

97+
--text::
98+
Treat all files as text.
99+
100+
-a::
101+
Shorthand for "--text".
102+
97103
For more detailed explanation on these common options, see also
98104
link:diffcore.html[diffcore documentation].

diff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ static void builtin_diff(const char *name_a,
729729
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
730730
die("unable to read files to diff");
731731

732-
if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) {
732+
if (!o->text && (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2))) {
733733
/* Quite common confusing case */
734734
if (mf1.size == mf2.size &&
735735
!memcmp(mf1.ptr, mf2.ptr, mf1.size))
@@ -1567,6 +1567,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
15671567
options->output_format |= DIFF_FORMAT_PATCH;
15681568
options->full_index = options->binary = 1;
15691569
}
1570+
else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) {
1571+
options->text = 1;
1572+
}
15701573
else if (!strcmp(arg, "--name-only"))
15711574
options->output_format |= DIFF_FORMAT_NAME;
15721575
else if (!strcmp(arg, "--name-status"))

diff.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct diff_options {
4242
unsigned recursive:1,
4343
tree_in_recursive:1,
4444
binary:1,
45+
text:1,
4546
full_index:1,
4647
silent_on_remove:1,
4748
find_copies_harder:1,
@@ -161,7 +162,8 @@ extern void diffcore_std_no_resolve(struct diff_options *);
161162
" -O<file> reorder diffs according to the <file>.\n" \
162163
" -S<string> find filepair whose only one side contains the string.\n" \
163164
" --pickaxe-all\n" \
164-
" show all files diff when -S is used and hit is found.\n"
165+
" show all files diff when -S is used and hit is found.\n" \
166+
" -a --text treat all files as text.\n"
165167

166168
extern int diff_queue_is_empty(void);
167169
extern void diff_flush(struct diff_options*);

0 commit comments

Comments
 (0)