X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2Fgcf2_libgit2.h;h=e1f0ef39a68623baf45c30c285324b8dfbc502ef;hb=23af251dd607c4e75ab1e68063f2c885c48cc035;hp=d9c79cf9b138df9b716df9035001ffba943b5274;hpb=e2f85d6bda87a8c6b25cc340b569ba0a20c2a1eb;p=public-inbox.git
diff --git a/lib/PublicInbox/gcf2_libgit2.h b/lib/PublicInbox/gcf2_libgit2.h
index d9c79cf9..e1f0ef39 100644
--- a/lib/PublicInbox/gcf2_libgit2.h
+++ b/lib/PublicInbox/gcf2_libgit2.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 all contributors
+ * Copyright (C) 2020-2021 all contributors
* License: AGPL-3.0+
*
* libgit2 for Inline::C
@@ -52,9 +52,13 @@ void add_alternate(SV *self, const char *objects_path)
croak_if_err(rc, "git_odb_add_disk_alternate");
}
-/* this requires an unabbreviated git OID */
#define CAPA(v) (sizeof(v) / sizeof((v)[0]))
-void cat_oid(SV *self, int fd, SV *oidsv)
+
+/*
+ * returns true on success, false on failure
+ * this requires an unabbreviated git OID
+ */
+int cat_oid(SV *self, int fd, SV *oidsv)
{
/*
* adjust when libgit2 gets SHA-256 support, we return the
@@ -89,11 +93,8 @@ void cat_oid(SV *self, int fd, SV *oidsv)
git_object_type2string(
git_odb_object_type(object)),
vec[1].iov_len);
- } else {
- vec[0].iov_base = oidptr;
- vec[0].iov_len = oidlen;
- vec[1].iov_base = " missing";
- vec[1].iov_len = strlen(vec[1].iov_base);
+ } else { /* caller retries */
+ nvec = 0;
}
while (nvec && !err) {
ssize_t w = writev(fd, vec + CAPA(vec) - nvec, nvec);
@@ -136,4 +137,6 @@ void cat_oid(SV *self, int fd, SV *oidsv)
git_odb_object_free(object);
if (err)
croak("writev error: %s", strerror(err));
+
+ return rc == GIT_OK;
}