summaryrefslogtreecommitdiff
path: root/tests/libgit2/diff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-04-10 09:44:41 -0400
committerGitHub <noreply@github.com>2022-04-10 09:44:41 -0400
commit606afeda5a0ff4d7ccb1476428682e078364c24d (patch)
treef0ef597e2e292b69863796fc74dfac6384e883a0 /tests/libgit2/diff
parent2fc0fcb5d6827c4107c571a7a076d029f7d3c442 (diff)
parent71bb92b565c2e55265c65c02be38909e829cef65 (diff)
downloadlibgit2-606afeda5a0ff4d7ccb1476428682e078364c24d.tar.gz
Merge pull request #6244 from jorio/fix-diff_delta_format_path-crash
Fix crash when regenerating a patch with unquoted spaces in filename
Diffstat (limited to 'tests/libgit2/diff')
-rw-r--r--tests/libgit2/diff/parse.c26
1 files changed, 26 insertions, 0 deletions
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;