|
|
|
[PATCH 5/5] diff: --ignore-case | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
Teach the front-end to flip XDF_IGNORE_CASE bit with the options GNU diff
uses.
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
Documentation/diff-options.txt | 4 ++++
diff.c | 2 ++
t/lib-diff-alternative.sh | 45 ++++++++++++++++++++++++++++++++++++++--
t/t4033-diff-patience.sh | 6 ++++++
t/t4050-diff-histogram.sh | 2 ++
5 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 9f7cba2..791e07f 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -404,6 +404,10 @@ endif::git-format-patch[]
differences even if one line has whitespace where the other
line has none.
+--ignore-case::
+ Ignore changes in case only; only ASCII alphabet is supported for
+ now.
+
--inter-hunk-context=<lines>::
Show the context between diff hunks, up to the specified number
of lines, thereby fusing hunks that are close to each other.
diff --git a/diff.c b/diff.c
index 87b2ec1..d7604b7 100644
--- a/diff.c
+++ b/diff.c
@@ -3399,6 +3399,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);
else if (!strcmp(arg, "--ignore-space-at-eol"))
DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);
+ else if (!strcmp(arg, "--ignore-case"))
+ DIFF_XDL_SET(options, IGNORE_CASE);
else if (!strcmp(arg, "--patience"))
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
else if (!strcmp(arg, "--histogram"))
diff --git a/t/lib-diff-alternative.sh b/t/lib-diff-alternative.sh
index 75ffd91..45c665e 100644
--- a/t/lib-diff-alternative.sh
+++ b/t/lib-diff-alternative.sh
@@ -104,8 +104,9 @@ EOF
STRATEGY=$1
+ cmd='git diff --no-index'
test_expect_success "$STRATEGY diff" '
- test_must_fail git diff --no-index "--$STRATEGY" file1 file2 > output &&
+ test_must_fail $cmd ${STRATEGY:+"--$STRATEGY"} file1 file2 >output &&
test_cmp expect output
'
@@ -157,9 +158,49 @@ EOF
STRATEGY=$1
+ cmd='git diff --no-index'
test_expect_success 'completely different files' '
- test_must_fail git diff --no-index "--$STRATEGY" uniq1 uniq2 > output &&
+
+ test_must_fail $cmd ${STRATEGY:+"--$STRATEGY"} uniq1 uniq2 >output &&
test_cmp expect output
'
}
+test_diff_ignore () {
+
+ STRATEGY=$1
+
+ echo "A quick brown fox" >test.0
+ echo "A quick brown fox" >test-b
+ echo " A quick brownfox" >test-w
+ echo "A quick brown fox " >test--ignore-space-at-eol
+ echo "A Quick Brown Fox" >test--ignore-case
+ echo "A Quick Brown Fox" >test--ignore-case-b
+ echo "A quick brown fox jumps" >test
+ cases="-b -w --ignore-space-at-eol --ignore-case"
+
+ if test -z "$STRATEGY"
+ then
+ label=baseline
+ else
+ label=$STRATEGY
+ fi
+
+ cmd="git diff --no-index ${STRATEGY:+--$STRATEGY}"
+
+ test_expect_success "$label diff" '
+ test_must_fail $cmd test.0 test
+ '
+ for case in $cases
+ do
+ test_expect_success "$label diff $case" '
+ $cmd $case test.0 test$case &&
+ test_must_fail $cmd test.0 test
+ '
+ done
+
+ test_expect_success "$label diff -b --ignore-case" '
+ $cmd -b --ignore-case test.0 test--ignore-case-b
+ '
+
+}
diff --git a/t/t4033-diff-patience.sh b/t/t4033-diff-patience.sh
index 3c9932e..c7f8c6c 100755
--- a/t/t4033-diff-patience.sh
+++ b/t/t4033-diff-patience.sh
@@ -5,8 +5,14 @@ test_description='patience diff algorithm'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff-alternative.sh
+# baseline
+test_diff_unique ""
+test_diff_ignore ""
+
test_diff_frobnitz "patience"
test_diff_unique "patience"
+test_diff_ignore "patience"
+
test_done
diff --git a/t/t4050-diff-histogram.sh b/t/t4050-diff-histogram.sh
index fd3e86a..98c6686 100755
--- a/t/t4050-diff-histogram.sh
+++ b/t/t4050-diff-histogram.sh
@@ -9,4 +9,6 @@ test_diff_frobnitz "histogram"
test_diff_unique "histogram"
+test_diff_ignore "histogram"
+
test_done
--
1.7.9.1.265.g25f75
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Newbies FAQ] [Linux Kernel Development] [Free Online Dating] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Free Online Dating] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [Fedora Users] [Linux Resources]