]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4013-diff-various.sh
t3905: move all commands into test cases
[thirdparty/git.git] / t / t4013-diff-various.sh
index fa82b5a8eed4e0a8f9b350fba27bf0f21ebd1563..ce6aa3914fe74f037eb2451a88e36803594b0e78 100755 (executable)
@@ -5,7 +5,11 @@
 
 test_description='Various diff formatting options'
 
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
 
 test_expect_success setup '
 
@@ -342,6 +346,7 @@ log -SF master --max-count=2
 log -GF master
 log -GF -p master
 log -GF -p --pickaxe-all master
+log -IA -IB -I1 -I2 -p master
 log --decorate --all
 log --decorate=full --all
 
@@ -482,4 +487,43 @@ test_expect_success 'diff-tree --stdin with log formatting' '
        test_cmp expect actual
 '
 
+test_expect_success 'diff -I<regex>: setup' '
+       git checkout master &&
+       test_seq 50 >file0 &&
+       git commit -m "Set up -I<regex> test file" file0 &&
+       test_seq 50 | sed -e "s/13/ten and three/" -e "/7\$/d" >file0 &&
+       echo >>file0
+'
+test_expect_success 'diff -I<regex>' '
+       git diff --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual &&
+       cat >expect <<-\EOF &&
+       diff --git a/file0 b/file0
+       --- a/file0
+       +++ b/file0
+       @@ -34,7 +31,6 @@
+        34
+        35
+        36
+       -37
+        38
+        39
+        40
+       EOF
+       compare_diff_patch expect actual
+'
+
+test_expect_success 'diff -I<regex> --stat' '
+       git diff --stat --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual &&
+       cat >expect <<-\EOF &&
+        file0 | 1 -
+        1 file changed, 1 deletion(-)
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'diff -I<regex>: detect malformed regex' '
+       test_expect_code 129 git diff --ignore-matching-lines="^[124-9" 2>error &&
+       test_i18ngrep "invalid regex given to -I: " error
+'
+
 test_done