diff options
author | Nicolas Hake <nh@nosebud.de> | 2014-01-22 17:51:32 +0100 |
---|---|---|
committer | Nicolas Hake <nh@nosebud.de> | 2014-01-22 17:51:32 +0100 |
commit | c05cd7924d2409741bb4cb1eb3ba843bea7ec4a2 (patch) | |
tree | 548900c29909e116ec5c3c1fe41370bef3460ac5 /tests/diff/rename.c | |
parent | 450e8e9e623b8c172ba4628c146838cbf4c56519 (diff) | |
download | libgit2-c05cd7924d2409741bb4cb1eb3ba843bea7ec4a2.tar.gz |
Drop git_patch_to_str
It's hard or even impossible to correctly free the string buffer
allocated by git_patch_to_str in some circumstances. Drop the function
so people have to use git_patch_to_buf instead - git_buf has a dedicated
destructor.
Diffstat (limited to 'tests/diff/rename.c')
-rw-r--r-- | tests/diff/rename.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/diff/rename.c b/tests/diff/rename.c index 4d1f7646e..ca08d15f3 100644 --- a/tests/diff/rename.c +++ b/tests/diff/rename.c @@ -584,7 +584,7 @@ void test_diff_rename__patch(void) git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT; git_patch *patch; const git_diff_delta *delta; - char *text; + git_buf buf = GIT_BUF_INIT; const char *expected = "diff --git a/sixserving.txt b/ikeepsix.txt\nindex ad0a8e5..36020db 100644\n--- a/sixserving.txt\n+++ b/ikeepsix.txt\n@@ -1,3 +1,6 @@\n+I Keep Six Honest Serving-Men\n+=============================\n+\n I KEEP six honest serving-men\n (They taught me all I knew);\n Their names are What and Why and When\n@@ -21,4 +24,4 @@ She sends'em abroad on her own affairs,\n One million Hows, two million Wheres,\n And seven million Whys!\n \n- -- Rudyard Kipling\n+ -- Rudyard Kipling\n"; old_tree = resolve_commit_oid_to_tree(g_repo, sha0); @@ -610,9 +610,9 @@ void test_diff_rename__patch(void) cl_assert((delta = git_patch_get_delta(patch)) != NULL); cl_assert_equal_i(GIT_DELTA_COPIED, (int)delta->status); - cl_git_pass(git_patch_to_str(&text, patch)); - cl_assert_equal_s(expected, text); - git__free(text); + cl_git_pass(git_patch_to_buf(&buf, patch)); + cl_assert_equal_s(expected, buf.ptr); + git_buf_free(&buf); git_patch_free(patch); |