Merge branch 'ow/config-mailmap-pathname'
[gitweb.git] / t / t0008-ignores.sh
index b4d98e602f7422009599e58f0a7ae943476b1c7e..5ef5ad3db4f6c307e6bcf71f57dcdc4deaafc082 100755 (executable)
@@ -775,4 +775,58 @@ test_expect_success PIPE 'streaming support for --stdin' '
        echo "$response" | grep "^::    two"
 '
 
+############################################################################
+#
+# test whitespace handling
+
+test_expect_success 'trailing whitespace is ignored' '
+       mkdir whitespace &&
+       >whitespace/trailing &&
+       >whitespace/untracked &&
+       echo "whitespace/trailing   " >ignore &&
+       cat >expect <<EOF &&
+whitespace/untracked
+EOF
+       : >err.expect &&
+       git ls-files -o -X ignore whitespace >actual 2>err &&
+       test_cmp expect actual &&
+       test_cmp err.expect err
+'
+
+test_expect_success !MINGW 'quoting allows trailing whitespace' '
+       rm -rf whitespace &&
+       mkdir whitespace &&
+       >"whitespace/trailing  " &&
+       >whitespace/untracked &&
+       echo "whitespace/trailing\\ \\ " >ignore &&
+       echo whitespace/untracked >expect &&
+       : >err.expect &&
+       git ls-files -o -X ignore whitespace >actual 2>err &&
+       test_cmp expect actual &&
+       test_cmp err.expect err
+'
+
+test_expect_success NOT_MINGW,NOT_CYGWIN 'correct handling of backslashes' '
+       rm -rf whitespace &&
+       mkdir whitespace &&
+       >"whitespace/trailing 1  " &&
+       >"whitespace/trailing 2 \\\\" &&
+       >"whitespace/trailing 3 \\\\" &&
+       >"whitespace/trailing 4   \\ " &&
+       >"whitespace/trailing 5 \\ \\ " &&
+       >"whitespace/trailing 6 \\a\\" &&
+       >whitespace/untracked &&
+       echo "whitespace/trailing 1 \\    " >ignore  &&
+       echo "whitespace/trailing 2 \\\\\\\\\\\\\\\\" >>ignore &&
+       echo "whitespace/trailing 3 \\\\\\\\\\\\\\\\ " >>ignore &&
+       echo "whitespace/trailing 4   \\\\\\\\\\\\    " >>ignore &&
+       echo "whitespace/trailing 5 \\\\\\\\ \\\\\\\\\\\\   " >>ignore &&
+       echo "whitespace/trailing 6 \\\\\\\\a\\\\\\\\" >>ignore &&
+       echo whitespace/untracked >expect &&
+       >err.expect &&
+       git ls-files -o -X ignore whitespace >actual 2>err &&
+       test_cmp expect actual &&
+       test_cmp err.expect err
+'
+
 test_done