From 11866327d035b872603cdfa3635b836f92008190 Mon Sep 17 00:00:00 2001 From: Iliyas Jorio Date: Sun, 13 Mar 2022 17:36:48 +0100 Subject: test: add test that regenerates patches with spaces in filename This currently crashes, proposed fix in subsequent commit. --- tests/libgit2/diff/parse.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/libgit2/diff') diff --git a/tests/libgit2/diff/parse.c b/tests/libgit2/diff/parse.c index d3a0c8de6..9c3f798e4 100644 --- a/tests/libgit2/diff/parse.c +++ b/tests/libgit2/diff/parse.c @@ -431,6 +431,32 @@ void test_diff_parse__new_file_with_space(void) git_diff_free(diff); } +void test_diff_parse__new_file_with_space_and_regenerate_patch(void) +{ + const char *content = PATCH_ORIGINAL_NEW_FILE_WITH_SPACE; + git_diff *diff = NULL; + git_buf buf = GIT_BUF_INIT; + + cl_git_pass(git_diff_from_buffer(&diff, content, strlen(content))); + cl_git_pass(git_diff_to_buf(&buf, diff, GIT_DIFF_FORMAT_PATCH)); + + git_buf_dispose(&buf); + git_diff_free(diff); +} + +void test_diff_parse__delete_file_with_space_and_regenerate_patch(void) +{ + const char *content = PATCH_DELETE_FILE_WITH_SPACE; + git_diff *diff = NULL; + git_buf buf = GIT_BUF_INIT; + + cl_git_pass(git_diff_from_buffer(&diff, content, strlen(content))); + cl_git_pass(git_diff_to_buf(&buf, diff, GIT_DIFF_FORMAT_PATCH)); + + git_buf_dispose(&buf); + git_diff_free(diff); +} + void test_diff_parse__crlf(void) { const char *text = PATCH_CRLF; -- cgit v1.2.1