From 6d64ea965bc2894ef0aee16ac23a5e47f20eb824 Mon Sep 17 00:00:00 2001 From: Stephan Feder Date: Fri, 7 Jul 2006 12:33:57 +0200 Subject: Teach --text option to diff Add new item text to struct diff_options. If set then do not try to detect binary files. Signed-off-by: Stephan Feder Signed-off-by: Junio C Hamano diff --git a/diff.c b/diff.c index f0450a8..1f0219d 100644 --- a/diff.c +++ b/diff.c @@ -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)) @@ -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")) diff --git a/diff.h b/diff.h index d557394..f80f646 100644 --- 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, -- cgit v0.10.2-6-g49f6 From 63ac4501199ca768e95ad3442f6580e41a002a33 Mon Sep 17 00:00:00 2001 From: Stephan Feder Date: Fri, 7 Jul 2006 15:57:07 +0200 Subject: Teach diff -a as shorthand for --text Signed-off-by: Stephan Feder Signed-off-by: Junio C Hamano diff --git a/diff.c b/diff.c index 1f0219d..b423491 100644 --- a/diff.c +++ b/diff.c @@ -1561,7 +1561,7 @@ 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")) { + else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) { options->text = 1; } else if (!strcmp(arg, "--name-only")) -- cgit v0.10.2-6-g49f6 From ca49920f6f8e7de3463757662841c608ca978888 Mon Sep 17 00:00:00 2001 From: Stephan Feder Date: Fri, 7 Jul 2006 15:57:08 +0200 Subject: Add -a and --text to common diff options help Signed-off-by: Stephan Feder Signed-off-by: Junio C Hamano diff --git a/diff.h b/diff.h index f80f646..8ab0448 100644 --- a/diff.h +++ b/diff.h @@ -162,7 +162,8 @@ extern void diffcore_std_no_resolve(struct diff_options *); " -O reorder diffs according to the .\n" \ " -S 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*); -- cgit v0.10.2-6-g49f6 From d507bb15008d6ee657eebaf2803bf0964af12c93 Mon Sep 17 00:00:00 2001 From: Stephan Feder Date: Fri, 7 Jul 2006 15:57:09 +0200 Subject: diff-options: Explain --text and -a Signed-off-by: Stephan Feder Signed-off-by: Junio C Hamano diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index f523ec2..1a93629 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -94,5 +94,11 @@ 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]. -- cgit v0.10.2-6-g49f6