summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-15 03:46:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-15 03:46:39 (GMT)
commitdabdc0178ec043ad42f6b3ab80e54f9c9404ab42 (patch)
tree3d95ce8b23f406b2ad3a5cf4b708cc034b0810ca
parentf463cc5306dd25844195b167aee4e5642e3bad16 (diff)
parentc91841594c2f08bec0c8b2d46da27add18fb4854 (diff)
downloadgit-dabdc0178ec043ad42f6b3ab80e54f9c9404ab42.zip
git-dabdc0178ec043ad42f6b3ab80e54f9c9404ab42.tar.gz
git-dabdc0178ec043ad42f6b3ab80e54f9c9404ab42.tar.bz2
Merge branch 'rj/test-regex' into maint-1.7.11
* rj/test-regex: test-regex: Add a test to check for a bug in the regex routines
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rwxr-xr-xt/t0070-fundamental.sh5
-rw-r--r--test-regex.c20
4 files changed, 27 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index bf66648..f1acd3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -186,6 +186,7 @@
/test-mktemp
/test-parse-options
/test-path-utils
+/test-regex
/test-revision-walking
/test-run-command
/test-sha1
diff --git a/Makefile b/Makefile
index 1f72c1c..13293d3 100644
--- a/Makefile
+++ b/Makefile
@@ -495,6 +495,7 @@ TEST_PROGRAMS_NEED_X += test-mergesort
TEST_PROGRAMS_NEED_X += test-mktemp
TEST_PROGRAMS_NEED_X += test-parse-options
TEST_PROGRAMS_NEED_X += test-path-utils
+TEST_PROGRAMS_NEED_X += test-regex
TEST_PROGRAMS_NEED_X += test-revision-walking
TEST_PROGRAMS_NEED_X += test-run-command
TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 9bee8bf..da2c504 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -25,4 +25,9 @@ test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '
grep "cannotwrite/test" err
'
+test_expect_success 'check for a bug in the regex routines' '
+ # if this test fails, re-build git with NO_REGEX=1
+ test-regex
+'
+
test_done
diff --git a/test-regex.c b/test-regex.c
new file mode 100644
index 0000000..b5bfd54
--- /dev/null
+++ b/test-regex.c
@@ -0,0 +1,20 @@
+#include <git-compat-util.h>
+
+int main(int argc, char **argv)
+{
+ char *pat = "[^={} \t]+";
+ char *str = "={}\nfred";
+ regex_t r;
+ regmatch_t m[1];
+
+ if (regcomp(&r, pat, REG_EXTENDED | REG_NEWLINE))
+ die("failed regcomp() for pattern '%s'", pat);
+ if (regexec(&r, str, 1, m, 0))
+ die("no match of pattern '%s' to string '%s'", pat, str);
+
+ /* http://sourceware.org/bugzilla/show_bug.cgi?id=3957 */
+ if (m[0].rm_so == 3) /* matches '\n' when it should not */
+ die("regex bug confirmed: re-build git with NO_REGEX=1");
+
+ exit(0);
+}