Commit Diff


commit - f605b7655a235f6bd6473ca91ae9fb428ae1a74b
commit + a07b40efef09db014d4811fd1c3a2816537fb7b5
blob - 385ea8c6903bd7108ab3f4de6767bc377bb43dba
blob + 4745de0b61f8e8be97d67007beaa6d42af3c885d
--- gitwrapper/gitwrapper.c
+++ gitwrapper/gitwrapper.c
@@ -35,6 +35,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "got_lib_dial.h"
blob - e005dd95c74a3dc4b85d1743ab6f06987fe6dd26
blob + 01004be305ffcd67c3e65eee2369956e16f23b5c
--- 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 - d9e38491b237bfe21ddc56c9b1f852e33ccf0f95
blob + db150241b9721a0787decd36b9a7bec42d6f8490
--- 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 - b2c062ff0b66e4bbcd8fb7640e294e01722fad4c
blob + 127286a48554f9687ba552171a77f0e02cb100f7
--- gotd/gotd.h
+++ gotd/gotd.h
@@ -471,8 +471,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 - 1b5f5241eb90e8ea67907a8760ae3e8bb73ae4c0
blob + 1079ba420e428f74b5e0d57802e8426fac6eabb4
--- 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 - 376d807107d3ecb1a6f59bf7c8aaf4d8d0eba847
blob + e2d6d8e3db728cd0c119bc1fa84eecae6dfe9605
--- gotd/listen.c
+++ gotd/listen.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "got_compat.h"
blob - 1bafd105316d87c5c2e31cbd9217e6f18ce72997
blob + e57194c1b439e147659de38acc77b1ddfab8c286
--- gotd/notify.c
+++ gotd/notify.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_object.h"
 #include "got_path.h"
 
 #include "gotd.h"
blob - e7d8e3c316b024edf031e3c53176113960270d1d
blob + e54d1cdb100569c2221f6253b0e72a1f14710991
--- 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 - 957cb87ecdef45c6b44c8a009eb5acf4501eef09
blob + 7ae97a2ea2c9ad104e9bf109f4f1f342448ad8c8
--- gotd/repo_write.c
+++ gotd/repo_write.c
@@ -1628,17 +1628,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;
 
@@ -2025,42 +2021,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);
@@ -2072,24 +2062,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 *
@@ -2127,13 +2113,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 - 097136c53f3ca82936693247f38e330e98a50dc3
blob + 957c494161a4b5571e1dc7c481b20589934974d6
--- 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 - 63410da3130904a23fe9008f76f36dd436f5e107
blob + a663ee9a015fdd3d41974ce6ea958626d40bb8c4
--- 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"
 #include "got_compat.h"