summaryrefslogtreecommitdiff
path: root/tests/diff/submodules.c
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-01-22 09:35:25 -0800
committerVicent Marti <vicent@github.com>2014-01-22 09:35:25 -0800
commitec088fec9dc65621275b9f16d746820af67592de (patch)
tree548900c29909e116ec5c3c1fe41370bef3460ac5 /tests/diff/submodules.c
parentaf2b969b6f63dafa8c55b88cadbcc7631c2dd30b (diff)
parentc05cd7924d2409741bb4cb1eb3ba843bea7ec4a2 (diff)
downloadlibgit2-ec088fec9dc65621275b9f16d746820af67592de.tar.gz
Merge pull request #2069 from isilkor/patch_to_buf
Expose patch serialization to git_buf
Diffstat (limited to 'tests/diff/submodules.c')
-rw-r--r--tests/diff/submodules.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c
index 24545b2c7..da96ba9c5 100644
--- a/tests/diff/submodules.c
+++ b/tests/diff/submodules.c
@@ -13,13 +13,15 @@ void test_diff_submodules__cleanup(void)
{
}
+#define get_buf_ptr(buf) ((buf)->asize ? (buf)->ptr : NULL)
+
static void check_diff_patches_at_line(
git_diff *diff, const char **expected, const char *file, int line)
{
const git_diff_delta *delta;
git_patch *patch = NULL;
size_t d, num_d = git_diff_num_deltas(diff);
- char *patch_text;
+ git_buf buf = GIT_BUF_INIT;
for (d = 0; d < num_d; ++d, git_patch_free(patch)) {
cl_git_pass(git_patch_from_diff(&patch, diff, d));
@@ -33,16 +35,16 @@ static void check_diff_patches_at_line(
if (expected[d] && !strcmp(expected[d], "<SKIP>"))
continue;
if (expected[d] && !strcmp(expected[d], "<END>")) {
- cl_git_pass(git_patch_to_str(&patch_text, patch));
+ cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_at_line(!strcmp(expected[d], "<END>"), file, line);
}
- cl_git_pass(git_patch_to_str(&patch_text, patch));
+ cl_git_pass(git_patch_to_buf(&buf, patch));
clar__assert_equal(
file, line, "expected diff did not match actual diff", 1,
- "%s", expected[d], patch_text);
- git__free(patch_text);
+ "%s", expected[d], get_buf_ptr(&buf));
+ git_buf_free(&buf);
}
cl_assert_at_line(expected[d] && !strcmp(expected[d], "<END>"), file, line);