Merge branch 'sf/diff'
authorJunio C Hamano <junkio@cox.net>
Sun, 9 Jul 2006 07:52:36 +0000 (00:52 -0700)
committerJunio C Hamano <junkio@cox.net>
Sun, 9 Jul 2006 07:52:36 +0000 (00:52 -0700)
Documentation/diff-options.txt
diff.c
diff.h
index f523ec2fbea9a129294b960461c82382b41ac92d..1a936295d8944b3b52ac82aa806c007851ab0176 100644 (file)
        Swap two inputs; that is, show differences from index or
        on-disk file to tree contents.
 
+--text::
+       Treat all files as text.
+
+-a::
+       Shorthand for "--text".
+
 For more detailed explanation on these common options, see also
 link:diffcore.html[diffcore documentation].
diff --git a/diff.c b/diff.c
index aab246c97eb1660acfa231f7008180a12f6deb8d..3e26180f08204df2e7519e4613aa6e3e844e21b2 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -729,7 +729,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))
@@ -1567,6 +1567,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, "-a") || !strcmp(arg, "--text")) {
+               options->text = 1;
+       }
        else if (!strcmp(arg, "--name-only"))
                options->output_format |= DIFF_FORMAT_NAME;
        else if (!strcmp(arg, "--name-status"))
diff --git a/diff.h b/diff.h
index d5573947b3295a00258cec2cb07905da5a5b8292..8ab0448a12e163b0941c05aba4f0a4d9c7a6cfb7 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -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,
@@ -161,7 +162,8 @@ extern void diffcore_std_no_resolve(struct diff_options *);
 "  -O<file>      reorder diffs according to the <file>.\n" \
 "  -S<string>    find filepair whose only one side contains the string.\n" \
 "  --pickaxe-all\n" \
-"                show all files diff when -S is used and hit is found.\n"
+"                show all files diff when -S is used and hit is found.\n" \
+"  -a  --text    treat all files as text.\n"
 
 extern int diff_queue_is_empty(void);
 extern void diff_flush(struct diff_options*);