]> git.proxmox.com Git - libgit2.git/blobdiff - tests/refs/reflog/reflog_helpers.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / refs / reflog / reflog_helpers.c
index aecb78b02bd217cd5e50bbbb170e951583c8a71c..2ea41ee061e487570be17293e729a9e535bbaa2b 100644 (file)
@@ -2,8 +2,9 @@
 
 #include "repository.h"
 #include "reflog.h"
+#include "reflog_helpers.h"
 
-static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
+int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
 {
        char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ];
 
@@ -12,7 +13,7 @@ static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
        git_oid_tostr((char *)&old_oid, GIT_OID_HEXSZ, git_reflog_entry_id_old(entry));
        git_oid_tostr((char *)&new_oid, GIT_OID_HEXSZ, git_reflog_entry_id_new(entry));
 
-       return git_buf_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
+       return git_str_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
 }
 
 size_t reflog_entrycount(git_repository *repo, const char *name)
@@ -34,7 +35,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
 {
        git_reflog *log;
        const git_reflog_entry *entry;
-       git_buf result = GIT_BUF_INIT;
+       git_str result = GIT_STR_INIT;
 
        cl_git_pass(git_reflog_read(&log, repo, reflog));
        entry = git_reflog_entry_byindex(log, idx);
@@ -47,7 +48,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
                        if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_old(entry)) != 0) {
                                git_oid__writebuf(&result, "\tOld OID: \"", git_object_id(obj));
                                git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
-                               git_buf_puts(&result, "\"\n");
+                               git_str_puts(&result, "\"\n");
                        }
                        git_object_free(obj);
                } else {
@@ -56,7 +57,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
                        if (git_oid_cmp(oid, git_reflog_entry_id_old(entry)) != 0) {
                                git_oid__writebuf(&result, "\tOld OID: \"", oid);
                                git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
-                               git_buf_puts(&result, "\"\n");
+                               git_str_puts(&result, "\"\n");
                        }
                        git__free(oid);
                }
@@ -67,7 +68,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
                        if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_new(entry)) != 0) {
                                git_oid__writebuf(&result, "\tNew OID: \"", git_object_id(obj));
                                git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
-                               git_buf_puts(&result, "\"\n");
+                               git_str_puts(&result, "\"\n");
                        }
                        git_object_free(obj);
                } else {
@@ -76,26 +77,26 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
                        if (git_oid_cmp(oid, git_reflog_entry_id_new(entry)) != 0) {
                                git_oid__writebuf(&result, "\tNew OID: \"", oid);
                                git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
-                               git_buf_puts(&result, "\"\n");
+                               git_str_puts(&result, "\"\n");
                        }
                        git__free(oid);
                }
        }
 
        if (email && strcmp(email, git_reflog_entry_committer(entry)->email) != 0)
-               git_buf_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
+               git_str_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
 
        if (message) {
                const char *entry_msg = git_reflog_entry_message(entry);
                if (entry_msg == NULL) entry_msg = "";
 
                if (entry_msg && strcmp(message, entry_msg) != 0)
-                       git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
+                       git_str_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
        }
-       if (git_buf_len(&result) != 0)
-               clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
+       if (git_str_len(&result) != 0)
+               clar__fail(file, func, line, "Reflog entry mismatch", git_str_cstr(&result), 1);
 
-       git_buf_dispose(&result);
+       git_str_dispose(&result);
        git_reflog_free(log);
 }
 
@@ -103,17 +104,17 @@ void reflog_print(git_repository *repo, const char *reflog_name)
 {
        git_reflog *reflog;
        size_t idx;
-       git_buf out = GIT_BUF_INIT;
+       git_str out = GIT_STR_INIT;
 
        git_reflog_read(&reflog, repo, reflog_name);
 
        for (idx = 0; idx < git_reflog_entrycount(reflog); idx++) {
                const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, idx);
                reflog_entry_tostr(&out, entry);
-               git_buf_putc(&out, '\n');
+               git_str_putc(&out, '\n');
        }
 
-       fprintf(stderr, "%s", git_buf_cstr(&out));
-       git_buf_dispose(&out);
+       fprintf(stderr, "%s", git_str_cstr(&out));
+       git_str_dispose(&out);
        git_reflog_free(reflog);
 }