Commit Diff


commit - 5822e79e39a8777984e08b5d89a8c55d6aa0356d
commit + 53bf0b541977b66862040d4b633fb6b5d3a3c6c8
blob - 5d8f4c8b71e72109e36cd63e72e3f77d6e211bdd
blob + a1a8e70bcff43bc951fef97bb37e60985bb35f76
--- got/Makefile
+++ got/Makefile
@@ -6,7 +6,7 @@ PROG=		got
 SRCS=		got.c blame.c commit_graph.c delta.c diff.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
-		privsep.c reference.c repository.c sha1.c worktree.c \
+		privsep.c reference.c repository.c hash.c worktree.c \
 		worktree_open.c inflate.c buf.c rcsutil.c diff3.c lockfile.c \
 		deflate.c object_create.c delta_cache.c fetch.c \
 		gotconfig.c diff_main.c diff_atomize_text.c \
blob - ef6f8e38e4cc6e4b1ea84fc72c54665a093b32ab
blob + cc4991565d1474d6bb048dff63d3db36b10e23c8
--- gotadmin/Makefile
+++ gotadmin/Makefile
@@ -8,7 +8,7 @@ SRCS=		gotadmin.c \
 		inflate.c lockfile.c object.c object_cache.c object_create.c \
 		object_idset.c object_parse.c opentemp.c pack.c pack_create.c \
 		path.c privsep.c reference.c repository.c repository_admin.c \
-		worktree_open.c sha1.c bloom.c murmurhash2.c ratelimit.c \
+		worktree_open.c hash.c bloom.c murmurhash2.c ratelimit.c \
 		sigs.c buf.c date.c object_open_privsep.c \
 		read_gitconfig_privsep.c read_gotconfig_privsep.c \
 		pack_create_privsep.c pollfd.c reference_parse.c
blob - 079b3c530a2c1681a497b2d74a8c077a1528b18a
blob + 6f68586c640662cd888e740dc5acaa83e889d438
--- gotctl/Makefile
+++ gotctl/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		gotctl
 SRCS=		gotctl.c error.c imsg.c inflate.c object_parse.c path.c \
-		pollfd.c sha1.c
+		pollfd.c hash.c
 
 MAN =		${PROG}.8
 
blob - 9e2f3a3fe6ecbd861b2a0fecf13026d61c3d475b
blob + b7c896f3faf9b3cbecc58d07a2ad7f76b9226064
--- gotd/Makefile
+++ gotd/Makefile
@@ -14,7 +14,7 @@ SRCS=		gotd.c auth.c repo_read.c repo_write.c log.c pr
 		object.c object_cache.c object_create.c object_idset.c \
 		object_open_io.c object_parse.c opentemp.c pack.c path.c \
 		read_gitconfig.c read_gotconfig.c reference.c repository.c  \
-		sha1.c sigs.c pack_create_io.c pollfd.c reference_parse.c \
+		hash.c sigs.c pack_create_io.c pollfd.c reference_parse.c \
 		repo_imsg.c pack_index.c session.c
 
 MAN =		${PROG}.conf.5 ${PROG}.8
blob - add224699cba16029f54df09a6eb6251d2024151
blob + 86f2b6013f0c53e31f8adbc89cd954b062c2ee0b
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -51,7 +51,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_object_cache.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_gitproto.h"
 #include "got_lib_pack.h"
 #include "got_lib_repository.h"
blob - 72bc2318a2e2469d1d4a9457ed349c23d3702aea
blob + a4d19987c878bbc0be5a08026bc1ba88bf3a3f11
--- gotd/repo_imsg.c
+++ gotd/repo_imsg.c
@@ -31,7 +31,7 @@
 #include "got_error.h"
 #include "got_object.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 #include "gotd.h"
 #include "log.h"
blob - 5c07746639cfa5d1c884730820173d58ce732e99
blob + fa9d0fe7c98493ac9d2d6fa32f34baa5310f2e37
--- gotd/repo_read.c
+++ gotd/repo_read.c
@@ -41,7 +41,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_object_idset.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_pack.h"
 #include "got_lib_ratelimit.h"
 #include "got_lib_pack_create.h"
blob - 8e7887d1348abccd2ca9ecc170522756afa06398
blob + 9534a8dc0cbb055298ed2df9da2f4cc08ae9ad9f
--- gotd/repo_write.c
+++ gotd/repo_write.c
@@ -52,7 +52,7 @@
 #include "got_lib_repository.h"
 #include "got_lib_poll.h"
 
-#include "got_lib_sha1.h" /* XXX temp include for debugging */
+#include "got_lib_hash.h" /* XXX temp include for debugging */
 
 #include "log.h"
 #include "gotd.h"
blob - 5bab9972301d215e1afe68a371dab2c35484b9bd
blob + 8f00f2699c2d87d84a815df4188c27ed9fcc45c0
--- gotd/session.c
+++ gotd/session.c
@@ -41,7 +41,7 @@
 #include "got_reference.h"
 #include "got_opentemp.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_object_cache.h"
blob - 8cce24717276094756bd1d95fbe9d738ab14a8da
blob + 3772cc684ff07adb2559919352418b7232dc14ec
--- gotsh/Makefile
+++ gotsh/Makefile
@@ -3,7 +3,7 @@
 .include "../got-version.mk"
 
 PROG=		gotsh
-SRCS=		gotsh.c error.c pkt.c sha1.c serve.c path.c gitproto.c \
+SRCS=		gotsh.c error.c pkt.c hash.c serve.c path.c gitproto.c \
 		imsg.c inflate.c object_parse.c pollfd.c reference_parse.c
 
 MAN =		${PROG}.1
blob - 3ff6327350055dfdcfeb3094e2836fcdcda955dc
blob + c2c364ff9f79098f7f41fb01b58642d7fa2661f9
--- gotwebd/Makefile
+++ gotwebd/Makefile
@@ -12,7 +12,7 @@ SRCS =		config.c sockets.c log.c gotwebd.c parse.y pro
 SRCS +=		blame.c commit_graph.c delta.c diff.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
-		privsep.c reference.c repository.c sha1.c worktree.c \
+		privsep.c reference.c repository.c hash.c worktree.c \
 		utf8.c inflate.c buf.c rcsutil.c diff3.c \
 		lockfile.c deflate.c object_create.c delta_cache.c \
 		gotconfig.c diff_main.c diff_atomize_text.c diff_myers.c \
blob - 58d428b99c43b2fba80028b6233bcd4ff6c7e4a4
blob + 05240d53214a844ee3d7b7d988783c9e4cfd7147
--- gotwebd/libexec/got-read-blob/Makefile
+++ gotwebd/libexec/got-read-blob/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-blob
 SRCS=		got-read-blob.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 669332cc8be5487a26cc868b873f782c7e351623
blob + 1165c222b775505baa64d377371c136878c607c8
--- gotwebd/libexec/got-read-commit/Makefile
+++ gotwebd/libexec/got-read-commit/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-commit
 SRCS=		got-read-commit.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - d81d4666fc3206a3008ddfc673992c5ec3265bd9
blob + e7bc462853862dcc5569354205b83cfa255442c1
--- gotwebd/libexec/got-read-gitconfig/Makefile
+++ gotwebd/libexec/got-read-gitconfig/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-gitconfig
 SRCS=		got-read-gitconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c gitconfig.c pollfd.c
+		path.c privsep.c hash.c gitconfig.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - abc9574b7efb93c971c76b3576970c8c19ba0e14
blob + dba200d19f6705b4dd9f5cd7a449af9a216da7f3
--- gotwebd/libexec/got-read-gotconfig/Makefile
+++ gotwebd/libexec/got-read-gotconfig/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-gotconfig
 SRCS=		got-read-gotconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c parse.y pollfd.c
+		path.c privsep.c hash.c parse.y pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib \
 	-I${.CURDIR}/../../../libexec/got-read-gotconfig
blob - 1c3afaf56bad757cf3c8b9574bc12521adbda7bb
blob + 97907ead0bd33b477aa7c06d62d666b9c00564ab
--- gotwebd/libexec/got-read-object/Makefile
+++ gotwebd/libexec/got-read-object/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-object
 SRCS=		got-read-object.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 9c1bf08b6d1c6cea526cdb38361ef89dfce5bc32
blob + 12228b03188af547ebf7a86b8f434b966ed06b98
--- gotwebd/libexec/got-read-pack/Makefile
+++ gotwebd/libexec/got-read-pack/Makefile
@@ -4,7 +4,7 @@
 PROG=		got-read-pack
 SRCS=		got-read-pack.c delta.c error.c inflate.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c pack.c path.c \
-		privsep.c sha1.c delta_cache.c pollfd.c
+		privsep.c hash.c delta_cache.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 450ee15c54e4904304143c4129f1adf9fd085073
blob + e3695245b3e0161a86859b3cb3e10a413f4d74bb
--- gotwebd/libexec/got-read-tag/Makefile
+++ gotwebd/libexec/got-read-tag/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-tag
 SRCS=		got-read-tag.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - 20c0a23b3bf5a858afe4cd8a8e2d57c5194dd074
blob + db849065b699533903ca1e34443e2612c1983ec8
--- gotwebd/libexec/got-read-tree/Makefile
+++ gotwebd/libexec/got-read-tree/Makefile
@@ -3,7 +3,7 @@
 
 PROG=		got-read-tree
 SRCS=		got-read-tree.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../../include -I${.CURDIR}/../../../lib
 LDADD = -lutil -lz
blob - bdbc5a99e7ea3c65dc1025b229cb9088a2042092
blob + 83b488b1eeb279f409a37815878f9eb4f43aa0a3
--- lib/fetch.c
+++ lib/fetch.c
@@ -58,7 +58,7 @@
 #include "got_lib_object_parse.h"
 #include "got_lib_object_create.h"
 #include "got_lib_pack.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_privsep.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_repository.h"
blob - /dev/null
blob + 141cb2590fa14834c63381929a0a7438ae3e4556 (mode 644)
--- /dev/null
+++ lib/got_lib_hash.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define GOT_SHA1_STRING_ZERO "0000000000000000000000000000000000000000"
+
+int got_parse_xdigit(uint8_t *, const char *);
+int got_parse_sha1_digest(uint8_t *, const char *);
+char *got_sha1_digest_to_str(const uint8_t *, char *, size_t);
blob - 141cb2590fa14834c63381929a0a7438ae3e4556 (mode 644)
blob + /dev/null
--- lib/got_lib_sha1.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#define GOT_SHA1_STRING_ZERO "0000000000000000000000000000000000000000"
-
-int got_parse_xdigit(uint8_t *, const char *);
-int got_parse_sha1_digest(uint8_t *, const char *);
-char *got_sha1_digest_to_str(const uint8_t *, char *, size_t);
blob - /dev/null
blob + fb4d3a30adf9281507aea3424f4c2711b1d3a28c (mode 644)
--- /dev/null
+++ lib/hash.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sha1.h>
+#include <sha2.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include "got_lib_hash.h"
+
+int
+got_parse_xdigit(uint8_t *val, const char *hex)
+{
+	char *ep;
+	long lval;
+
+	errno = 0;
+	lval = strtol(hex, &ep, 16);
+	if (hex[0] == '\0' || *ep != '\0')
+		return 0;
+	if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
+		return 0;
+
+	*val = (uint8_t)lval;
+	return 1;
+}
+
+int
+got_parse_sha1_digest(uint8_t *digest, const char *line)
+{
+	uint8_t b = 0;
+	char hex[3] = {'\0', '\0', '\0'};
+	int i, j;
+
+	for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+		if (line[0] == '\0' || line[1] == '\0')
+			return 0;
+		for (j = 0; j < 2; j++) {
+			hex[j] = *line;
+			line++;
+		}
+		if (!got_parse_xdigit(&b, hex))
+			return 0;
+		digest[i] = b;
+	}
+
+	return 1;
+}
+
+char *
+got_sha1_digest_to_str(const uint8_t *digest, char *buf, size_t size)
+{
+	char *p = buf;
+	char hex[3];
+	int i;
+
+	if (size < SHA1_DIGEST_STRING_LENGTH)
+		return NULL;
+
+	for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+		snprintf(hex, sizeof(hex), "%.2x", digest[i]);
+		p[0] = hex[0];
+		p[1] = hex[1];
+		p += 2;
+	}
+	p[0] = '\0';
+
+	return buf;
+}
blob - 616110f7694a3b4c33137e816e98ec3fbd0ecc5f
blob + f8b902a4c27338568c455eb639ecba5cbb38b8c2
--- lib/object.c
+++ lib/object.c
@@ -40,7 +40,7 @@
 #include "got_opentemp.h"
 #include "got_path.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
blob - d7836025f28fa8cfc114d9547ac2e8fe42fe2ae2
blob + d703aefd6b522073c9b2c3c3eb7f2cff2a4e3590
--- lib/object_create.c
+++ lib/object_create.c
@@ -39,7 +39,7 @@
 #include "got_path.h"
 #include "got_sigs.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_deflate.h"
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
blob - 32f17a47aacb973f4a807a866c3255ce4c08b66b
blob + 67c3bc37ea78571d6f3c25478ae3e612ee235f22
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -43,7 +43,7 @@
 #include "got_opentemp.h"
 #include "got_path.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
blob - 963e51e80e8dce5ebf0447ca653e93ec258de3ad
blob + 41355efc540436f1b9cbb6f193ac0916c8dffb06
--- lib/pack.c
+++ lib/pack.c
@@ -40,7 +40,7 @@
 #include "got_object.h"
 #include "got_path.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_delta_cache.h"
 #include "got_lib_inflate.h"
blob - 109239b2d4894e2c87f0148253ee45502875815c
blob + d7107177f8056953e03aac01278c49f2aee6f81f
--- lib/pack_index.c
+++ lib/pack_index.c
@@ -44,7 +44,7 @@
 #include "got_error.h"
 #include "got_object.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
blob - 59a13dd810eba0402fc0b3ad5c4d0713a87dfb85
blob + 92514335bde2a392e0211cb8f5903c931aac55d2
--- lib/patch.c
+++ lib/patch.c
@@ -53,7 +53,7 @@
 #include "got_lib_diff.h"
 #include "got_lib_object.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
blob - 5b304a5c206ad19cabadd551ff22e8897385ff43
blob + b8ea370fd2e88931bfc3f441dded6c848d55b3bd
--- lib/privsep.c
+++ lib/privsep.c
@@ -40,7 +40,7 @@
 #include "got_path.h"
 #include "got_repository.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
blob - b795d720cf9c55ea4542c68394a7b8841836d4a8
blob + b7e19bcfc7a34cea70cf48a5c32ab66ee4acb857
--- lib/reference.c
+++ lib/reference.c
@@ -39,7 +39,7 @@
 #include "got_opentemp.h"
 #include "got_path.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
blob - 5d61c690e9148236fe594887d0f16180cd8b517d
blob + abff91e2c234cdd1c87f05d07d2a9d02a0cc98e4
--- lib/repository.c
+++ lib/repository.c
@@ -61,7 +61,7 @@
 #include "got_lib_object_create.h"
 #include "got_lib_pack.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_repository.h"
 #include "got_lib_gotconfig.h"
blob - 12e06fd9d03b90c1baa018420815850bc60771d3
blob + d552b4a35a689baa8cf628c010eb5adfc9d57ce4
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -54,7 +54,7 @@
 #include "got_lib_repository.h"
 #include "got_lib_ratelimit.h"
 #include "got_lib_pack_create.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_lockfile.h"
 
 #ifndef nitems
blob - b264f31e208d68ff02d735e05bef2a7e740ffffb
blob + 3b9f271aa9ce3830585ef554b0f559c8e5ea026e
--- lib/send.c
+++ lib/send.c
@@ -61,7 +61,7 @@
 #include "got_lib_object_parse.h"
 #include "got_lib_object_create.h"
 #include "got_lib_pack.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_privsep.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_repository.h"
blob - 5c3d04049bbcd0db1d1c39d9f4cab4f3b0ff4e82
blob + ecd71cee9f0fb1d68f5a2341e98bfa386fb743c0
--- lib/serve.c
+++ lib/serve.c
@@ -40,7 +40,7 @@
 #include "got_lib_pkt.h"
 #include "got_lib_dial.h"
 #include "got_lib_gitproto.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_poll.h"
 
 #include "gotd.h"
blob - ee835ad4c90671b4fd6fd88951b7b5c716f05bce (mode 644)
blob + /dev/null
--- lib/sha1.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <sha1.h>
-#include <sha2.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-
-#include "got_lib_sha1.h"
-
-int
-got_parse_xdigit(uint8_t *val, const char *hex)
-{
-	char *ep;
-	long lval;
-
-	errno = 0;
-	lval = strtol(hex, &ep, 16);
-	if (hex[0] == '\0' || *ep != '\0')
-		return 0;
-	if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
-		return 0;
-
-	*val = (uint8_t)lval;
-	return 1;
-}
-
-int
-got_parse_sha1_digest(uint8_t *digest, const char *line)
-{
-	uint8_t b = 0;
-	char hex[3] = {'\0', '\0', '\0'};
-	int i, j;
-
-	for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
-		if (line[0] == '\0' || line[1] == '\0')
-			return 0;
-		for (j = 0; j < 2; j++) {
-			hex[j] = *line;
-			line++;
-		}
-		if (!got_parse_xdigit(&b, hex))
-			return 0;
-		digest[i] = b;
-	}
-
-	return 1;
-}
-
-char *
-got_sha1_digest_to_str(const uint8_t *digest, char *buf, size_t size)
-{
-	char *p = buf;
-	char hex[3];
-	int i;
-
-	if (size < SHA1_DIGEST_STRING_LENGTH)
-		return NULL;
-
-	for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
-		snprintf(hex, sizeof(hex), "%.2x", digest[i]);
-		p[0] = hex[0];
-		p[1] = hex[1];
-		p += 2;
-	}
-	p[0] = '\0';
-
-	return buf;
-}
blob - acd8307b04275b541a9891ab3fbfdeeeb432edef
blob + d7bd842e2f1e138573c94334a50105954443372d
--- lib/worktree.c
+++ lib/worktree.c
@@ -47,7 +47,7 @@
 #include "got_diff.h"
 
 #include "got_lib_worktree.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_fileindex.h"
 #include "got_lib_inflate.h"
 #include "got_lib_delta.h"
blob - 7158a0e8c0ec73671b1e74d1affd3176244fbe9e
blob + ae942231a4113ed60cf12a3cd075564ca02dd988
--- libexec/got-fetch-pack/Makefile
+++ libexec/got-fetch-pack/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-fetch-pack
 SRCS=		got-fetch-pack.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pkt.c gitproto.c ratelimit.c \
+		path.c privsep.c hash.c pkt.c gitproto.c ratelimit.c \
 		pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 0d6a2fdb3fcbc261da832889417e85438d3189ba
blob + 9182db0e5c9f34de75291565e8162a16cda84db4
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
@@ -43,7 +43,7 @@
 #include "got_fetch.h"
 #include "got_reference.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
blob - c2f4952a5ecb70a6ecdb061eef225def26c15c75
blob + 92a354326a20f1fee1023a18f5b058b069586c0a
--- libexec/got-index-pack/Makefile
+++ libexec/got-index-pack/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-index-pack
 SRCS=		got-index-pack.c error.c inflate.c object_parse.c object_idset.c \
-		delta_cache.c delta.c pack.c path.c privsep.c sha1.c ratelimit.c \
+		delta_cache.c delta.c pack.c path.c privsep.c hash.c ratelimit.c \
 		pack_index.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 10fa486bce699c88c8487b34007e1ab262a1d1a8
blob + 23ce4ec071efb8c72e90c5c8eca304ea20056375
--- libexec/got-read-blob/Makefile
+++ libexec/got-read-blob/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-blob
 SRCS=		got-read-blob.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - dec93a8e7676ff3c05faf46924a6572bf79f53ea
blob + f13607515ea61ff5d111d7206363d56b58d23aa3
--- libexec/got-read-commit/Makefile
+++ libexec/got-read-commit/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-commit
 SRCS=		got-read-commit.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 06fd0ccf9175b92f3f512b27d34a8a5831d48edd
blob + 0d5a81cd2be10724bfca5d40fe59053215b749e3
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
@@ -39,7 +39,7 @@
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 static volatile sig_atomic_t sigint_received;
 
blob - 25a30ce385a81305898d16ab8b87121528f7e630
blob + 5aa516cfcc8b0ad54ab77d31ee508cf18811d3e4
--- libexec/got-read-gitconfig/Makefile
+++ libexec/got-read-gitconfig/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-gitconfig
 SRCS=		got-read-gitconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c gitconfig.c pollfd.c
+		path.c privsep.c hash.c gitconfig.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - ea559ac400e6c69dfb837d062a2dce93c449ba46
blob + 8cc878c329d0556ead75d394fec706c1b95d416e
--- libexec/got-read-gotconfig/Makefile
+++ libexec/got-read-gotconfig/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-gotconfig
 SRCS=		got-read-gotconfig.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c parse.y pollfd.c
+		path.c privsep.c hash.c parse.y pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib -I${.CURDIR}
 
blob - 1e6ac4a2c151ff6879da233913d87c73a8f74d31
blob + 73b38413ebe7843e58920f98b259e1505bf4b1f5
--- libexec/got-read-object/Makefile
+++ libexec/got-read-object/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-object
 SRCS=		got-read-object.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 45455f641f9fb218d9f0b5d8509545f391463427
blob + 4396edfaac8ae4bf97e83da86f49717f922fdee0
--- libexec/got-read-object/got-read-object.c
+++ libexec/got-read-object/got-read-object.c
@@ -39,7 +39,7 @@
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 #ifndef nitems
 #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
blob - 2d45d0f0c9ea5186421438239984f9606128b553
blob + 23067a70e47387cb0d2dc4cbafc14e62e542a662
--- libexec/got-read-pack/Makefile
+++ libexec/got-read-pack/Makefile
@@ -5,7 +5,7 @@
 PROG=		got-read-pack
 SRCS=		got-read-pack.c delta.c error.c inflate.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c pack.c path.c \
-		privsep.c sha1.c delta_cache.c pollfd.c
+		privsep.c hash.c delta_cache.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - dbd3afa62f25910a42da355909407617dc6c1be7
blob + a9a8b307200d2da9499202b060147e7f7933d122
--- libexec/got-read-patch/Makefile
+++ libexec/got-read-patch/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-patch
 SRCS=		got-read-patch.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - e5ac12f4b2c21aec7fcbb05d9dd0b32cb70c59ba
blob + 4849e5e3e5d7c3c90f43a4b6a30f2e39b23f2820
--- libexec/got-read-patch/got-read-patch.c
+++ libexec/got-read-patch/got-read-patch.c
@@ -57,7 +57,7 @@
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 struct imsgbuf ibuf;
 
blob - 54a41c2feaca0262542136fa53e0e55842246d6a
blob + e8e772933d6d6a5e5df33d1a2339dd897f353b1b
--- libexec/got-read-tag/Makefile
+++ libexec/got-read-tag/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-tag
 SRCS=		got-read-tag.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - 0eba8437b5a4386da5c346a01bf741aa1b1ecd33
blob + 9a510beab9f689e0356e77e698d30b666c6f4521
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
@@ -39,7 +39,7 @@
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 static volatile sig_atomic_t sigint_received;
 
blob - 4312c216c70d94a4b1678f9cca0fd1d41608c347
blob + 17c93154615fbf085466a3685f96d9058b259ec9
--- libexec/got-read-tree/Makefile
+++ libexec/got-read-tree/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-read-tree
 SRCS=		got-read-tree.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pollfd.c
+		path.c privsep.c hash.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 
blob - dadab5108323c038a93c499449fdab2599dda988
blob + b8c40928c6dbf801b5730c92cd5ada9803a890d1
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
@@ -40,7 +40,7 @@
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
 #include "got_lib_privsep.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 
 static volatile sig_atomic_t sigint_received;
 
blob - 07a27f7715950303cc9130d9ed1920c3bd9ec96c
blob + ab90d8b29f892ebe8290f3c9234bd433093bd865
--- libexec/got-send-pack/Makefile
+++ libexec/got-send-pack/Makefile
@@ -4,7 +4,7 @@
 
 PROG=		got-send-pack
 SRCS=		got-send-pack.c error.c inflate.c object_parse.c \
-		path.c privsep.c sha1.c pkt.c gitproto.c ratelimit.c \
+		path.c privsep.c hash.c pkt.c gitproto.c ratelimit.c \
 		pollfd.c reference_parse.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 5fcc44c06073be44e528183f338257c89eab9f9d
blob + d1ffc719f8ca4925cb7bf8c3d4e5c8180824fb64
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
@@ -44,7 +44,7 @@
 #include "got_fetch.h"
 #include "got_reference.h"
 
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
 #include "got_lib_object_parse.h"
blob - 7c1c0a3a874d31efc8dfdaaf62f35c2f29701ee5
blob + 475dd4289d617e4ccfde05e7dd965aadacae6aff
--- regress/delta/Makefile
+++ regress/delta/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = delta_test
-SRCS = delta.c error.c opentemp.c path.c inflate.c sha1.c delta_test.c \
+SRCS = delta.c error.c opentemp.c path.c inflate.c hash.c delta_test.c \
 	pollfd.c object_parse.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 31a968efd9dc6f1669b141bb1dfea69b5cc8abbb
blob + c89d76ee9c4539c7d7c3907089ab2b233a8744a2
--- regress/deltify/Makefile
+++ regress/deltify/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = deltify_test
-SRCS = deltify.c error.c opentemp.c sha1.c deltify_test.c murmurhash2.c \
+SRCS = deltify.c error.c opentemp.c hash.c deltify_test.c murmurhash2.c \
 	object_parse.c inflate.c path.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 70bf4f896a17b76140e11c227248938fe1c0ac7a
blob + 4c3c7abb0a9b0de487050e9bc9149cb0d46f9749
--- regress/fetch/Makefile
+++ regress/fetch/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = fetch_test
-SRCS = error.c privsep.c reference.c sha1.c object.c object_parse.c path.c \
+SRCS = error.c privsep.c reference.c hash.c object.c object_parse.c path.c \
 	opentemp.c repository.c lockfile.c object_cache.c pack.c inflate.c \
 	deflate.c delta.c delta_cache.c object_idset.c object_create.c \
 	fetch.c gotconfig.c dial.c fetch_test.c bloom.c murmurhash2.c sigs.c \
blob - e4defb763447ad087297a8dbd741450eb4563f04
blob + c024c69ae8a0fd18330ae5c8f6dc6b872026966e
--- regress/fetch/fetch_test.c
+++ regress/fetch/fetch_test.c
@@ -35,7 +35,7 @@
 #include "got_dial.h"
 
 #include "got_lib_object_idset.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_inflate.h"
 #include "got_lib_delta.h"
 
blob - f835e9f283dceca9d301438c5813505b06d0aa43
blob + 6b78a4717b9682af0793283e080f4458ab6a8b8e
--- regress/idset/Makefile
+++ regress/idset/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = idset_test
-SRCS = error.c sha1.c object_idset.c inflate.c path.c object_parse.c \
+SRCS = error.c hash.c object_idset.c inflate.c path.c object_parse.c \
 	idset_test.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 686196fc5aecb11d94216d1536ba42fd2acaaf77
blob + 511fd016b578a9308aede2f46618c2b7b6a353c2
--- regress/idset/idset_test.c
+++ regress/idset/idset_test.c
@@ -31,7 +31,7 @@
 #include "got_object.h"
 
 #include "got_lib_object_idset.h"
-#include "got_lib_sha1.h"
+#include "got_lib_hash.h"
 #include "got_lib_inflate.h"
 #include "got_lib_delta.h"
 #include "got_lib_object.h"
blob - 213cea213945e44b6aa28f0953faf6657f8c5a41
blob + 23a916db855dd46d0844a60ae1b609c2e9c37279
--- regress/path/Makefile
+++ regress/path/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = path_test
-SRCS = error.c path.c sha1.c path_test.c object_parse.c inflate.c pollfd.c
+SRCS = error.c path.c hash.c path_test.c object_parse.c inflate.c pollfd.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
blob - 426283795a3cb7ae2b87d51af958f4315f3a5f30
blob + 89e400f4320fe358711e282ef7a72ddfa0b30e80
--- tog/Makefile
+++ tog/Makefile
@@ -6,7 +6,7 @@ PROG=		tog
 SRCS=		tog.c blame.c commit_graph.c delta.c diff.c \
 		diffreg.c error.c fileindex.c object.c object_cache.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
-		privsep.c reference.c repository.c sha1.c worktree.c \
+		privsep.c reference.c repository.c hash.c worktree.c \
 		worktree_open.c utf8.c inflate.c buf.c rcsutil.c diff3.c \
 		lockfile.c deflate.c object_create.c delta_cache.c \
 		gotconfig.c diff_main.c diff_atomize_text.c \