From 9d65360b4eaa402c8f137684577d0131a861ce8b Mon Sep 17 00:00:00 2001 From: Erik Aigner Date: Fri, 29 Mar 2019 12:30:37 +0100 Subject: tests: diff: test parsing diffs with a new file with spaces in its path Add a test that verifies that we are able to parse patches which add a new file that has spaces in its path. --- tests/diff/parse.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/diff/parse.c') diff --git a/tests/diff/parse.c b/tests/diff/parse.c index 9cdaa92fb..7cc468245 100644 --- a/tests/diff/parse.c +++ b/tests/diff/parse.c @@ -359,3 +359,21 @@ void test_diff_parse__lineinfo(void) git_patch_free(patch); git_diff_free(diff); } + +void test_diff_parse__new_file_with_space(void) +{ + const char *content = PATCH_ORIGINAL_NEW_FILE_WITH_SPACE; + git_patch *patch; + git_diff *diff; + + cl_git_pass(git_diff_from_buffer(&diff, content, strlen(content))); + cl_git_pass(git_patch_from_diff((git_patch **) &patch, diff, 0)); + + cl_assert_equal_p(patch->diff_opts.old_prefix, NULL); + cl_assert_equal_p(patch->delta->old_file.path, NULL); + cl_assert_equal_s(patch->diff_opts.new_prefix, "b/"); + cl_assert_equal_s(patch->delta->new_file.path, "sp ace.txt"); + + git_patch_free(patch); + git_diff_free(diff); +} -- cgit v1.2.1