summaryrefslogtreecommitdiff
path: root/tests/diff/parse.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-04-04 14:04:59 -0700
committerGitHub <noreply@github.com>2019-04-04 14:04:59 -0700
commit6bcb7357eccdab4de948af55836ce25f76dd7270 (patch)
treef59a2f5076ebcfef5fa0a559f0ac474dcf43d5f5 /tests/diff/parse.c
parent18e836cbf3f01d1aaa839315efb2c0cf0e6b2204 (diff)
parent9d65360b4eaa402c8f137684577d0131a861ce8b (diff)
downloadlibgit2-6bcb7357eccdab4de948af55836ce25f76dd7270.tar.gz
Merge pull request #5035 from pks-t/pks/diff-with-space-in-filenames
patch_parse: fix parsing addition/deletion of file with space
Diffstat (limited to 'tests/diff/parse.c')
-rw-r--r--tests/diff/parse.c18
1 files changed, 18 insertions, 0 deletions
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);
+}