]> git.proxmox.com Git - libgit2.git/blobdiff - tests/apply/fromfile.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / apply / fromfile.c
index 31fffa1a2bf47f8e62a8a078806c74b2bebd390a..8cde623928a89aed18a7cbfb62efc2c6fb507c1f 100644 (file)
@@ -5,7 +5,6 @@
 #include "patch.h"
 #include "patch_parse.h"
 #include "repository.h"
-#include "buf_text.h"
 
 #include "../patch/patch_common.h"
 
@@ -31,27 +30,28 @@ static int apply_patchfile(
        unsigned int mode_expected)
 {
        git_patch *patch;
-       git_buf result = GIT_BUF_INIT;
-       git_buf patchbuf = GIT_BUF_INIT;
+       git_str result = GIT_STR_INIT;
+       git_str patchbuf = GIT_STR_INIT;
        char *filename;
        unsigned int mode;
        int error;
 
        cl_git_pass(git_patch_from_buffer(&patch, patchfile, strlen(patchfile), NULL));
 
-       error = git_apply__patch(&result, &filename, &mode, old, old_len, patch);
+       error = git_apply__patch(&result, &filename, &mode, old, old_len, patch, NULL);
 
        if (error == 0) {
                cl_assert_equal_i(new_len, result.size);
-               cl_assert(memcmp(new, result.ptr, new_len) == 0);
+               if (new_len)
+                       cl_assert(memcmp(new, result.ptr, new_len) == 0);
 
                cl_assert_equal_s(filename_expected, filename);
                cl_assert_equal_i(mode_expected, mode);
        }
 
        git__free(filename);
-       git_buf_free(&result);
-       git_buf_free(&patchbuf);
+       git_str_dispose(&result);
+       git_str_dispose(&patchbuf);
        git_patch_free(patch);
 
        return error;
@@ -81,7 +81,7 @@ static int validate_and_apply_patchfile(
 
        error = apply_patchfile(old, old_len, new, new_len, patchfile, filename_expected, mode_expected);
 
-       git_buf_free(&validated);
+       git_buf_dispose(&validated);
        git_patch_free(patch_fromdiff);
 
        return error;