{"thread":{"id":"31405","subject":"[PATCH v2] test-regex: Add a test to check for a bug in the regex routines","startedAt":"2012-09-01T17:46:54Z","lastAt":"2012-09-01T17:46:54Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"198198","messageId":"50424A0E.60402@ramsay1.demon.co.uk","threadId":"31405","inReplyTo":null,"subject":"[PATCH v2] test-regex: Add a test to check for a bug in the regex routines","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-09-01T17:46:54Z","receivedAt":"2012-09-01T17:46:54Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n .gitignore             |  1 +\n Makefile               |  1 +\n t/t0070-fundamental.sh |  5 +++++\n test-regex.c           | 20 ++++++++++++++++++++\n 4 files changed, 27 insertions(+)\n create mode 100644 test-regex.c\n\ndiff --git a/.gitignore b/.gitignore\nindex bb5c91e..68fe464 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -189,6 +189,7 @@\n /test-mktemp\n /test-parse-options\n /test-path-utils\n+/test-regex\n /test-revision-walking\n /test-run-command\n /test-sha1\ndiff --git a/Makefile b/Makefile\nindex 6b0c961..3b760d3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -496,6 +496,7 @@ TEST_PROGRAMS_NEED_X += test-mergesort\n TEST_PROGRAMS_NEED_X += test-mktemp\n TEST_PROGRAMS_NEED_X += test-parse-options\n TEST_PROGRAMS_NEED_X += test-path-utils\n+TEST_PROGRAMS_NEED_X += test-regex\n TEST_PROGRAMS_NEED_X += test-revision-walking\n TEST_PROGRAMS_NEED_X += test-run-command\n TEST_PROGRAMS_NEED_X += test-scrap-cache-tree\ndiff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh\nindex 9bee8bf..da2c504 100755\n--- a/t/t0070-fundamental.sh\n+++ b/t/t0070-fundamental.sh\n@@ -25,4 +25,9 @@ test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '\n \tgrep \"cannotwrite/test\" err\n '\n \n+test_expect_success 'check for a bug in the regex routines' '\n+\t# if this test fails, re-build git with NO_REGEX=1\n+\ttest-regex\n+'\n+\n test_done\ndiff --git a/test-regex.c b/test-regex.c\nnew file mode 100644\nindex 0000000..b5bfd54\n--- /dev/null\n+++ b/test-regex.c\n@@ -0,0 +1,20 @@\n+#include <git-compat-util.h>\n+\n+int main(int argc, char **argv)\n+{\n+\tchar *pat = \"[^={} \\t]+\";\n+\tchar *str = \"={}\\nfred\";\n+\tregex_t r;\n+\tregmatch_t m[1];\n+\n+\tif (regcomp(&r, pat, REG_EXTENDED | REG_NEWLINE))\n+\t\tdie(\"failed regcomp() for pattern '%s'\", pat);\n+\tif (regexec(&r, str, 1, m, 0))\n+\t\tdie(\"no match of pattern '%s' to string '%s'\", pat, str);\n+\n+\t/* http://sourceware.org/bugzilla/show_bug.cgi?id=3957  */\n+\tif (m[0].rm_so == 3) /* matches '\\n' when it should not */\n+\t\tdie(\"regex bug confirmed: re-build git with NO_REGEX=1\");\n+\n+\texit(0);\n+}\n-- \n1.7.12\n"}]}