diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-07-20 11:06:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-20 11:06:23 +0100 |
| commit | f33ca472d1a160ab5abbdf07d434455d7d1ee15c (patch) | |
| tree | d24aa48e2fba6e4517ca8a613e295d7d1c9bfeb7 /tests/patch | |
| parent | d78a1b186d4c05e0be8c47d445e1149d393d6b43 (diff) | |
| parent | dedf70ad2b9f3dd5a5b299f64476285653cf62b7 (diff) | |
| download | libgit2-f33ca472d1a160ab5abbdf07d434455d7d1ee15c.tar.gz | |
Merge pull request #5158 from pks-t/pks/patch-parsed-lifetime
patch_parse: do not depend on parsed buffer's lifetime
Diffstat (limited to 'tests/patch')
| -rw-r--r-- | tests/patch/parse.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/patch/parse.c b/tests/patch/parse.c index a40ad7b23..7eb987920 100644 --- a/tests/patch/parse.c +++ b/tests/patch/parse.c @@ -108,3 +108,23 @@ void test_patch_parse__files_with_whitespaces_succeeds(void) cl_git_pass(git_patch_from_buffer(&patch, PATCH_NAME_WHITESPACE, strlen(PATCH_NAME_WHITESPACE), NULL)); git_patch_free(patch); } + +void test_patch_parse__lifetime_of_patch_does_not_depend_on_buffer(void) +{ + git_buf diff = GIT_BUF_INIT, rendered = GIT_BUF_INIT; + git_patch *patch; + + cl_git_pass(git_buf_sets(&diff, PATCH_ORIGINAL_TO_CHANGE_MIDDLE)); + cl_git_pass(git_patch_from_buffer(&patch, diff.ptr, diff.size, NULL)); + git_buf_dispose(&diff); + + cl_git_pass(git_patch_to_buf(&rendered, patch)); + cl_assert_equal_s(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, rendered.ptr); + git_buf_dispose(&rendered); + + cl_git_pass(git_patch_to_buf(&rendered, patch)); + cl_assert_equal_s(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, rendered.ptr); + git_buf_dispose(&rendered); + + git_patch_free(patch); +} |
