Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-08-15 19:46:38 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-08-15 19:46:38 +0300
commite451cd5c0350aa70e05df44bbf5cbdc0e6504f46 (patch)
tree4b33b940c850db82d4ee6c6c5251150662a55d15 /tests
parent755004eaed008779bed9e5efb8b539917dbf431b (diff)
diff: don't error out on an invalid regex
When parsing user-provided regex patterns for functions, we must not fail to provide a diff just because a pattern is not well formed. Ignore it instead.
Diffstat (limited to 'tests')
-rw-r--r--tests/diff/drivers.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c
index e3a0014db..42af38a9a 100644
--- a/tests/diff/drivers.c
+++ b/tests/diff/drivers.c
@@ -250,3 +250,29 @@ void test_diff_drivers__builtins(void)
git_buf_free(&expected);
git_vector_free(&files);
}
+
+void test_diff_drivers__invalid_pattern(void)
+{
+ git_config *cfg;
+ git_index *idx;
+ git_diff *diff;
+ git_patch *patch;
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+
+ g_repo = cl_git_sandbox_init("userdiff");
+ cl_git_mkfile("userdiff/.gitattributes", "*.storyboard diff=storyboard\n");
+
+ cl_git_pass(git_repository_config__weakptr(&cfg, g_repo));
+ cl_git_pass(git_config_set_string(cfg, "diff.storyboard.xfuncname", "<!--(.*?)-->"));
+
+ cl_git_mkfile("userdiff/dummy.storyboard", "");
+ cl_git_pass(git_repository_index__weakptr(&idx, g_repo));
+ cl_git_pass(git_index_add_bypath(idx, "dummy.storyboard"));
+ cl_git_mkfile("userdiff/dummy.storyboard", "some content\n");
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_patch_from_diff(&patch, diff, 0));
+
+ git_patch_free(patch);
+ git_diff_free(diff);
+}