Commit Diff


commit - 5813d178aff670a67346e23851a985a8530a8d33
commit + 095892882c4ccc2f584998552200561f340e060f
blob - ca9b00397c9f4b9743440e020914a5be8ea662d7
blob + 106fa01cdcb16ebcfb3d4274fd2a3f883de11933
--- include/got_error.h
+++ include/got_error.h
@@ -74,6 +74,9 @@
 #define GOT_ERR_TREE_DUP_ENTRY	58
 #define GOT_ERR_DIR_DUP_ENTRY	59
 #define GOT_ERR_NOT_WORKTREE	60
+#define GOT_ERR_UUID_VERSION	61
+#define GOT_ERR_UUID_INVALID	62
+#define GOT_ERR_UUID		63
 
 static const struct got_error {
 	int code;
@@ -138,6 +141,9 @@ static const struct got_error {
 	{ GOT_ERR_TREE_DUP_ENTRY,"duplicate entry in tree object" },
 	{ GOT_ERR_DIR_DUP_ENTRY,"duplicate entry in directory" },
 	{ GOT_ERR_NOT_WORKTREE, "no got work tree found" },
+	{ GOT_ERR_UUID_VERSION, "bad uuid version" },
+	{ GOT_ERR_UUID_INVALID, "uuid invalid" },
+	{ GOT_ERR_UUID,		"uuid error" },
 };
 
 /*
@@ -190,3 +196,6 @@ const struct got_error *got_error_no_obj(struct got_ob
  * message set during earlier invocations.
  */
 const struct got_error *got_error_not_ref(const char *);
+
+/* Return an error based on a uuid(3) status code. */
+const struct got_error *got_error_uuid(uint32_t);
blob - 72cf6ae7f1505bf4f6059b6384a1f700ea922bbd
blob + 737359cf3aae1b0bca724c568acc3c9b7949928c
--- lib/error.c
+++ lib/error.c
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <sha1.h>
 #include <zlib.h>
+#include <uuid.h>
 
 #include "got_error.h"
 #include "got_object.h"
@@ -120,3 +121,20 @@ got_error_not_ref(const char *refname)
 
 	return got_error_msg(GOT_ERR_NOT_REF, msg);
 }
+
+const struct got_error *
+got_error_uuid(uint32_t uuid_status)
+{
+	switch (uuid_status) {
+	case uuid_s_ok:
+		return NULL;
+	case uuid_s_bad_version:
+		return got_error(GOT_ERR_UUID_VERSION);
+	case uuid_s_invalid_string_uuid:
+		return got_error(GOT_ERR_UUID_INVALID);
+	case uuid_s_no_memory:
+		return got_error_set_errno(ENOMEM);
+	default:
+		return got_error(GOT_ERR_UUID);
+	}
+}