Download raw body.
sprinkle some got_object_id over uint8 buffers in gotd
this will make my work for sha256 easier. (i.e. will let gotd compile with other changes I'm doing, pretty sure it will still explode at runtime) IMHO here it makes sense to pass around an id instead of buffer with the hash, if only since it saves some lines ;) ok? diff /home/op/w/got commit - 75e58d893ea728a250b35dff13d82123aaabc9f0 path + /home/op/w/got blob - 326421d114b5877a893a1f63613d87e64dde3559 file + gitwrapper/gitwrapper.c --- 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 file + gotctl/gotctl.c --- 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 file + gotd/auth.c --- 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 file + gotd/gotd.h --- 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 file + gotd/imsg.c --- 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 file + gotd/listen.c --- 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 file + gotd/notify.c --- 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 file + gotd/parse.y --- 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 file + gotd/repo_write.c --- 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 file + gotd/session_write.c --- 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(¬if->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(¬if->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(¬if->old_id, &icontent.old_id, + sizeof(notif->old_id)) != 0 || + memcmp(¬if->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 file + gotsh/gotsh.c --- 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"
sprinkle some got_object_id over uint8 buffers in gotd