Commit Diff


commit - 50eb7cdf4a2cf4faa7b494ffd0520471b93905e7
commit + 1b1a386df9068b7cb3ceb8a67d88ccd24f5b2deb
blob - 326421d114b5877a893a1f63613d87e64dde3559
blob + 0c22d1dced690c764d8a882746e76ec45a9c7226
--- gitwrapper/gitwrapper.c
+++ gitwrapper/gitwrapper.c
@@ -37,6 +37,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "got_lib_dial.h"
blob - 02cc7ea7b999fff68dd0fd76a0015622e5c99b68
blob + f0b3e23dc8afc1dde424443e06cb5831714793d0
--- gotctl/gotctl.c
+++ gotctl/gotctl.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_version.h"
 #include "got_path.h"
 
blob - 66b5696fc0fe4bca89de497a5be81b41c9d65b52
blob + 80c9ed0ee1c0db65d55b64e028363e68817afbed
--- gotd/auth.c
+++ gotd/auth.c
@@ -36,6 +36,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "gotd.h"
blob - a5beda9391d602dffa305641b74ab2961e50f0b4
blob + c51b69d2d80fd63e6ed9b528b0fb749a764c65d7
--- gotd/gotd.h
+++ gotd/gotd.h
@@ -468,8 +468,8 @@ enum gotd_notification_action {
 /* IMSG_NOTIFY session <-> repo_write */
 struct gotd_imsg_notification_content {
 	enum gotd_notification_action action;
-	uint8_t old_id[SHA1_DIGEST_LENGTH];
-	uint8_t new_id[SHA1_DIGEST_LENGTH];
+	struct got_object_id old_id;
+	struct got_object_id new_id;
 	size_t refname_len;
 	/* Followed by refname_len data bytes. */
 };
blob - 86b16615f22802ae9f3a4f249265458eb1392651
blob + 992bb231e5877b491084348026d517514e382805
--- gotd/imsg.c
+++ gotd/imsg.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "got_lib_poll.h"
blob - 23dd87f8191b27375b82a3f72a796826d19990e2
blob + 095d9d88dc8766d8898eddbfe0a5b3be4387afd8
--- gotd/listen.c
+++ gotd/listen.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "gotd.h"
blob - f0029122659d6d4bf4190d611c2223d8d4d6f55d
blob + 20958912de97f4002cb2fa805ef1624b48a47647
--- gotd/notify.c
+++ gotd/notify.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "gotd.h"
blob - 5c541845a38938fd010b806b6893f3b106de2d28
blob + 775f13f301bbb2743b0dd8d3cea68054ca32e779
--- gotd/parse.y
+++ gotd/parse.y
@@ -44,6 +44,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 #include "got_reference.h"
 
blob - a409328c01fae5d0f4136cddf2e34b224469bbc2
blob + 65e8d06c9243e84fd149a9a8f68dc5afe4032615
--- gotd/repo_write.c
+++ gotd/repo_write.c
@@ -1630,17 +1630,13 @@ receive_pack_idx(struct imsg *imsg, struct gotd_imsgev
 }
 
 static const struct got_error *
-notify_removed_ref(const char *refname, uint8_t *sha1,
+notify_removed_ref(const char *refname, struct got_object_id *id,
     struct gotd_imsgev *iev, int fd)
 {
 	const struct got_error *err;
-	struct got_object_id id;
 	char *id_str;
 
-	memset(&id, 0, sizeof(id));
-	memcpy(id.sha1, sha1, sizeof(id.sha1));
-
-	err = got_object_id_str(&id_str, &id);
+	err = got_object_id_str(&id_str, id);
 	if (err)
 		return err;
 
@@ -2027,42 +2023,36 @@ done:
 }
 
 static const struct got_error *
-notify_changed_ref(const char *refname, uint8_t *old_sha1,
-    uint8_t *new_sha1, struct gotd_imsgev *iev, int fd)
+notify_changed_ref(const char *refname, struct got_object_id *old_id,
+    struct got_object_id *new_id, struct gotd_imsgev *iev, int fd)
 {
 	const struct got_error *err;
-	struct got_object_id old_id, new_id;
 	int old_obj_type, new_obj_type;
 	const char *label;
 	char *new_id_str = NULL;
 
-	memset(&old_id, 0, sizeof(old_id));
-	memcpy(old_id.sha1, old_sha1, sizeof(old_id.sha1));
-	memset(&new_id, 0, sizeof(new_id));
-	memcpy(new_id.sha1, new_sha1, sizeof(new_id.sha1));
-
-	err = got_object_get_type(&old_obj_type, repo_write.repo, &old_id);
+	err = got_object_get_type(&old_obj_type, repo_write.repo, old_id);
 	if (err)
 		return err;
 
-	err = got_object_get_type(&new_obj_type, repo_write.repo, &new_id);
+	err = got_object_get_type(&new_obj_type, repo_write.repo, new_id);
 	if (err)
 		return err;
 
 	switch (new_obj_type) {
 	case GOT_OBJ_TYPE_COMMIT:
-		err = print_commits(&new_id,
-		    old_obj_type == GOT_OBJ_TYPE_COMMIT ? &old_id : NULL,
+		err = print_commits(new_id,
+		    old_obj_type == GOT_OBJ_TYPE_COMMIT ? old_id : NULL,
 		    repo_write.repo, fd);
 		break;
 	case GOT_OBJ_TYPE_TAG:
-		err = print_tag(&new_id, refname, repo_write.repo, fd);
+		err = print_tag(new_id, refname, repo_write.repo, fd);
 		break;
 	default:
 		err = got_object_type_label(&label, new_obj_type);
 		if (err)
 			goto done;
-		err = got_object_id_str(&new_id_str, &new_id);
+		err = got_object_id_str(&new_id_str, new_id);
 		if (err)
 			goto done;
 		dprintf(fd, "%s: %s object %s\n", refname, label, new_id_str);
@@ -2074,24 +2064,20 @@ done:
 }
 
 static const struct got_error *
-notify_created_ref(const char *refname, uint8_t *sha1,
+notify_created_ref(const char *refname, struct got_object_id *id,
     struct gotd_imsgev *iev, int fd)
 {
 	const struct got_error *err;
-	struct got_object_id id;
 	int obj_type;
 
-	memset(&id, 0, sizeof(id));
-	memcpy(id.sha1, sha1, sizeof(id.sha1));
-
-	err = got_object_get_type(&obj_type, repo_write.repo, &id);
+	err = got_object_get_type(&obj_type, repo_write.repo, id);
 	if (err)
 		return err;
 
 	if (obj_type == GOT_OBJ_TYPE_TAG)
-		return print_tag(&id, refname, repo_write.repo, fd);
+		return print_tag(id, refname, repo_write.repo, fd);
 
-	return print_commits(&id, NULL, repo_write.repo, fd);
+	return print_commits(id, NULL, repo_write.repo, fd);
 }
 
 static const struct got_error *
@@ -2129,13 +2115,13 @@ render_notification(struct imsg *imsg, struct gotd_ims
 
 	switch (ireq.action) {
 	case GOTD_NOTIF_ACTION_CREATED:
-		err = notify_created_ref(refname, ireq.new_id, iev, fd);
+		err = notify_created_ref(refname, &ireq.new_id, iev, fd);
 		break;
 	case GOTD_NOTIF_ACTION_REMOVED:
-		err = notify_removed_ref(refname, ireq.old_id, iev, fd);
+		err = notify_removed_ref(refname, &ireq.old_id, iev, fd);
 		break;
 	case GOTD_NOTIF_ACTION_CHANGED:
-		err = notify_changed_ref(refname, ireq.old_id, ireq.new_id,
+		err = notify_changed_ref(refname, &ireq.old_id, &ireq.new_id,
 		    iev, fd);
 		break;
 	}
blob - c21d1c02dd99282f345f37e8dc6e2cb64c1e65b5
blob + 6c9c61a414a0d5c844ce86e60e9544b213cd637c
--- gotd/session_write.c
+++ gotd/session_write.c
@@ -523,23 +523,23 @@ forward_notification(struct gotd_session_client *clien
 		goto done;
 	}
 	if (notif->action == GOTD_NOTIF_ACTION_CREATED) {
-		if (memcmp(notif->new_id.sha1, icontent.new_id,
-		    SHA1_DIGEST_LENGTH) != 0) {
+		if (memcmp(&notif->new_id, &icontent.new_id,
+		    sizeof(notif->new_id)) != 0) {
 			err = got_error_msg(GOT_ERR_PRIVSEP_MSG,
 			    "received notification content for unknown event");
 			goto done;
 		}
 	} else if (notif->action == GOTD_NOTIF_ACTION_REMOVED) {
-		if (memcmp(notif->old_id.sha1, icontent.old_id,
-		    SHA1_DIGEST_LENGTH) != 0) {
+		if (memcmp(&notif->old_id, &icontent.old_id,
+		    sizeof(notif->old_id)) != 0) {
 			err = got_error_msg(GOT_ERR_PRIVSEP_MSG,
 			    "received notification content for unknown event");
 			goto done;
 		}
-	} else if (memcmp(notif->old_id.sha1, icontent.old_id,
-	    SHA1_DIGEST_LENGTH) != 0 ||
-	    memcmp(notif->new_id.sha1, icontent.new_id,
-	    SHA1_DIGEST_LENGTH) != 0) {
+	} else if (memcmp(&notif->old_id, &icontent.old_id,
+	    sizeof(notif->old_id)) != 0 ||
+	    memcmp(&notif->new_id, &icontent.new_id,
+	    sizeof(notif->old_id)) != 0) {
 		err = got_error_msg(GOT_ERR_PRIVSEP_MSG,
 		    "received notification content for unknown event");
 		goto done;
blob - 2523b2c27285f8b883a18bfa1d16fb268ff9cd5c
blob + c578f8cbb9a1c2672039a719cdba04b4eacdb8d9
--- gotsh/gotsh.c
+++ gotsh/gotsh.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_serve.h"
 #include "got_path.h"