Commit Diff


commit - 0926e3456c5719c231467a4c7e4481f9e355d968094709ac24e515c928e579e5
commit + 9527045ad78ba956142e13a60fdf5dbdb803203d6c922fdbb40b45b272974f6b
blob - c9ff7977d366ee884d0c05b11d3b4dada58a41fc0a03645e25148045f83a6443
blob + 14e54601fef7683d97ad6aecba4f4682a9a53842fa22a448b3890dd848380803
--- gotsys/gotsys.conf.5	
+++ gotsys/gotsys.conf.5	
@@ -290,6 +290,18 @@ parameter can only contain one line of text in ASCII e
 or in UTF-8 encoding if
 .Ar string
 is wrapped in quotes.
+.It Ic hash algorithm Ar hashing-algorithm
+Configure the repository's
+.Ar hashing-algorithm
+used for the computation of Git object IDs.
+Possible values are
+.Dq sha1
+.Pq the default
+or
+.Dq sha256 .
+.Pp
+This configuration directive only affects newly created repositories.
+The hashing algorithm of existing repositories cannot be changed.
 .It Ic head Ar branch
 Point the repository's symbolic
 .Pa HEAD
blob - 3358507cfcd8b986b18dc1cde941db274388257fa71093ecd8a18bdfc3d4af67
blob + 2b568ab8ec90874385848adc84b5694efea6e0800a86c013a6027a93857b3473
--- gotsys/gotsys.h	
+++ gotsys/gotsys.h	
@@ -146,6 +146,7 @@ struct gotsys_repo {
 	char name[NAME_MAX];
 	char *headref;
 	char description[GOTWEBD_MAXDESCRSZ];
+	enum got_hash_algorithm algo;
 
 	struct gotsys_access_rule_list access_rules;
 
@@ -216,6 +217,8 @@ const struct got_error *gotsys_conf_parse_url(char **,
     char **, const char *);
 const struct got_error *gotsys_conf_validate_mediatype(const char *);
 const struct got_error *gotsys_conf_validate_string(const char *);
+const struct got_error *gotsys_conf_validate_hash_algo(
+    enum got_hash_algorithm *, const char *);
 const struct got_error *gotsys_conf_new_access_rule(
     struct gotsys_access_rule **, enum gotsys_access, int, const char *,
     struct gotsys_userlist *, struct gotsys_grouplist *);
blob - 19e734522e24fb9706609b7392514d0bb2e36788183834ba98cb3cfb3b02ecf9
blob + 5c40e8e5af2f41cd914dd6ff4a1e49c31f1e0d6292f3e45f3207d372ec54b90b
--- gotsys/parse.y	
+++ gotsys/parse.y	
@@ -130,6 +130,7 @@ typedef struct {
 %token	NOTIFY EMAIL FROM REPLY TO URL INSECURE HMAC HEAD WEB SERVER
 %token	HIDE REPOSITORIES STYLESHEET LOGO SITE OWNER WEBSITE PATH
 %token	DISABLE ENABLE AUTHENTICATION MEDIA TYPES DESCRIPTION
+%token	HASH ALGORITHM
 
 %token	<v.string>	STRING
 %token	<v.number>	NUMBER
@@ -614,6 +615,18 @@ repoopts1	: PERMIT RO numberstring {
 			}
 			free($2);
 		}
+		| HASH ALGORITHM STRING {
+			const struct got_error *err;
+
+			err = gotsys_conf_validate_hash_algo(&new_repo->algo,
+			    $3);
+			if (err) {
+				yyerror("%s", err->msg);
+				free($3);
+				YYERROR;
+			}
+			free($3);
+		}
 		;
 
 webrepo		: REPOSITORY STRING {
@@ -1263,6 +1276,7 @@ lookup(char *s)
 {
 	/* This has to be sorted always. */
 	static const struct keywords keywords[] = {
+		{ "algorithm",			ALGORITHM },
 		{ "authentication",		AUTHENTICATION },
 		{ "authorized",			AUTHORIZED },
 		{ "branch",			BRANCH },
@@ -1273,6 +1287,7 @@ lookup(char *s)
 		{ "enable",			ENABLE },
 		{ "from",			FROM },
 		{ "group",			GROUP },
+		{ "hash",			HASH },
 		{ "head",			HEAD },
 		{ "hide",			HIDE },
 		{ "hmac",			HMAC },
blob - 5cc79791938726d4a4744617b44443ae1f117e6fd472e133fc95539764871ee9
blob + 2bd0ac207a8a992374227e20e0bc16214f7b4d622c0cfc20be46e9d25ddd36ab
--- gotsysd/gotsysd.h	
+++ gotsysd/gotsysd.h	
@@ -450,6 +450,7 @@ struct gotsysd_imsg_sysconf_rmkeys_param {
 
 /* Structture for GOTSYSD_IMSG_SYSCONF_REPO_CREATE. */
 struct gotsysd_imsg_sysconf_repo_create {
+	int algo;
 	size_t name_len;
 	size_t headref_len;
 
@@ -514,6 +515,7 @@ struct gotsysd_imsg_sysconf_authorized_key {
 
 /* Structure for GOTSYSD_IMSG_SYSCONF_REPO, */
 struct gotsysd_imsg_sysconf_repo {
+	int algo;
 	size_t name_len;
 	size_t headref_len;
 	size_t description_len;
blob - a0fb9594eb1e360c5bb70229bf9ea3275d0f9936fa8b70cec0def8572754a3f2
blob + 676e58a60c88b9443fb7398e03ea50e470addb8917834717bada46d865b16116
--- gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
+++ gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
@@ -228,6 +228,10 @@ create_repo(struct imsg *imsg)
 	    param.name_len == 0)
 		return got_error(GOT_ERR_PRIVSEP_LEN);
 
+	err = got_hash_algo_validate(param.algo);
+	if (err)
+		goto done;
+
 	repo_name = strndup(imsg->data + sizeof(param), param.name_len);
 	if (repo_name == NULL)
 		return got_error_from_errno("strndup");
@@ -291,7 +295,7 @@ create_repo(struct imsg *imsg)
 		} else
 			err = got_error_from_errno2("mkdir", abspath);
 	} else
-		err = got_repo_init(abspath, head_name, GOT_HASH_SHA1);
+		err = got_repo_init(abspath, head_name, param.algo);
 done:
 	free(repo_name);
 	free(fullname);
blob - b4521fbb075ae4947c20623684947cc5e48bffd1f9a3b0d1a7d23a4dc6114718
blob + 15251606c56643656f0757030e1a99700c93131e1e5144796f26068751aeb03b
--- gotsysd/sysconf.c	
+++ gotsysd/sysconf.c	
@@ -1220,6 +1220,8 @@ create_repos(struct gotsysd_imsgev *iev)
 
 		memset(&ireq, 0, sizeof(ireq));
 
+		ireq.algo = repo->algo;
+
 		ireq.name_len = strlen(repo->name);
 		if (repo->headref)
 			ireq.headref_len = strlen(repo->headref);
blob - fe646dc5260b25fd92307a8d994ce11030eaba4cfc3687a7b57805cbf550dd07
blob + bb85b7cf6e5e3355fb249bd89b035bcfae16e63bd4a9875038fb5193702bdce5
--- include/got_object.h	
+++ include/got_object.h	
@@ -26,6 +26,12 @@ enum got_hash_algorithm {
 	GOT_NUM_HASH_ALGOS,
 };
 
+/* Return a human-readable name of the hash algorithm. */
+const char *got_hash_algo_name(enum got_hash_algorithm);
+
+/* Return an error if the specified algorithm is out of range. */
+const struct got_error *got_hash_algo_validate(enum got_hash_algorithm);
+
 struct got_object_id {
 	uint8_t hash[GOT_OBJECT_ID_MAXLEN];
 	enum got_hash_algorithm algo;
blob - 9034eebaf7171669ea3c0c0541e2d3b44ad19877d8bd96ab05212ab53bd6a525
blob + 5b24106921d1a132bab4f5643f099673bbe3967dedf3e48bc38493d86dfabb73
--- lib/got_lib_hash.h	
+++ lib/got_lib_hash.h	
@@ -84,6 +84,3 @@ void	got_hash_final_object_id(struct got_hash *, struc
  * Compare two hash digest; similar to memcmp().
  */
 int	got_hash_cmp(enum got_hash_algorithm, uint8_t *, uint8_t *);
-
-/* Return a human-readable name of the hash algorithm. */
-const char *got_hash_algo_name(enum got_hash_algorithm);
blob - d75967e32aa3420e270c1c069bf43ed4e334e1b0243106a8f5ac05c9a29da554
blob + 7ceb0a59bddfe52ae4864af5b75a73a2ae01e41727605da621f7c13d91cf90cd
--- lib/gotsys_conf.c	
+++ lib/gotsys_conf.c	
@@ -39,6 +39,8 @@
 #include "gotsys.h"
 #include "utf8d.h"
 
+#include "got_lib_hash.h"
+
 #ifndef nitems
 #define nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
 #endif
@@ -906,6 +908,8 @@ gotsys_conf_new_repo(struct gotsys_repo **new_repo, co
 		    "repository name too long: %s", name);
 	}
 
+	repo->algo = GOT_HASH_SHA1;
+
 	*new_repo = repo;
 	return NULL;
 }
@@ -1368,6 +1372,21 @@ gotsys_conf_validate_string(const char *s)
 	return NULL;
 }
 
+const struct got_error *
+gotsys_conf_validate_hash_algo(enum got_hash_algorithm *algo, const char *name)
+{
+	int i = 0;
+
+	for (i = 0; i < GOT_NUM_HASH_ALGOS; i++) {
+		if (strcasecmp(name, got_hash_algo_name(i)) == 0) {
+			*algo = i;
+			return NULL;
+		}
+	}
+
+	return got_error_fmt(GOT_ERR_OBJECT_FORMAT, "%s", name);
+}
+
 struct gotsys_repo *
 gotsys_find_repo_by_name(const char *repo_name, struct gotsys_repolist *repos)
 {
blob - 00824b174c59b4eb0cbb7c0af3268eede16687bfe1a0bd51f9133f8e342bb40b
blob + 8d8f055b45c24676bc6c9224184d4421684e6cc39f970b23335a613d8d362647
--- lib/gotsys_imsg.c	
+++ lib/gotsys_imsg.c	
@@ -1416,6 +1416,7 @@ send_repo(struct gotsysd_imsgev *iev, struct gotsys_re
 
 	memset(&irepo, 0, sizeof(irepo));
 
+	irepo.algo = repo->algo;
 	irepo.name_len = strlen(repo->name);
 	if (repo->headref)
 		irepo.headref_len = strlen(repo->headref);
@@ -1707,6 +1708,10 @@ gotsys_imsg_recv_repository(struct gotsys_repo **repo,
 	    irepo.name_len == 0)
 		return got_error(GOT_ERR_PRIVSEP_LEN);
 
+	err = got_hash_algo_validate(irepo.algo);
+	if (err)
+		goto done;
+
 	name = strndup(imsg->data + sizeof(irepo), irepo.name_len);
 	if (name == NULL)
 		return got_error_from_errno("strndup");
@@ -1758,6 +1763,7 @@ gotsys_imsg_recv_repository(struct gotsys_repo **repo,
 	if (err)
 		goto done;
 
+	(*repo)->algo = irepo.algo;
 	(*repo)->headref = headref;
 	if (description != NULL) {
 		if (strlcpy((*repo)->description, description,
blob - 47a0706f58d6dbae63d0c112c235e145bbae8429c27c3d3d41b85dd5fd90658f
blob + a8f33fb02291dee6a53f9a4a9a13ae05dc777d57797593c7dbbb200d08ad51c7
--- lib/hash.c	
+++ lib/hash.c	
@@ -261,3 +261,16 @@ got_hash_algo_name(enum got_hash_algorithm algo)
 		return "unknown";
 	}
 }
+
+const struct got_error *
+got_hash_algo_validate(enum got_hash_algorithm algo)
+{
+	switch (algo) {
+	case GOT_HASH_SHA1:
+		return NULL;
+	case GOT_HASH_SHA256:
+		return NULL;
+	default:
+		return got_error(GOT_ERR_OBJECT_FORMAT);
+	}
+}
blob - 0aa2fe071737a49dbfe329c62750867b57620d176fd66e0ca17cce641f97ae25
blob + d2bde910a9ab6c7054a1b40db804ed149a92501da62204665de52615a41f8a23
--- regress/gotsysd/Makefile	
+++ regress/gotsysd/Makefile	
@@ -41,6 +41,7 @@ GOTSYSD_TEST_HTTP_PORT=8000
 GOTSYSD_TEST_HMAC_SECRET!=openssl rand -base64 32
 HTTPD_CONF=httpd.conf
 SSHD_CONF=sshd_config
+GOT_TEST_ALGO=sha1
 
 GOTSYSD_TEST_USER?=${DOAS_USER}
 .if empty(GOTSYSD_TEST_USER)
@@ -68,7 +69,8 @@ GOTSYSD_TEST_ENV=GOTSYSD_TEST_ROOT=${GOTSYSD_TEST_ROOT
 	GOTD_USER=${GOTD_USER} \
 	GOTSYSD_TEST_SMTP_PORT=${GOTSYSD_TEST_SMTP_PORT} \
 	GOTSYSD_TEST_HTTP_PORT=${GOTSYSD_TEST_HTTP_PORT} \
-	GOTSYSD_TEST_HMAC_SECRET=${GOTSYSD_TEST_HMAC_SECRET}
+	GOTSYSD_TEST_HMAC_SECRET=${GOTSYSD_TEST_HMAC_SECRET} \
+	GOT_TEST_ALGO=${GOT_TEST_ALGO}
 
 
 UNPRIV=su -m ${GOTSYSD_TEST_USER} -c
@@ -218,6 +220,7 @@ ${GOTSYS_CONF}: ${GOTSYSD_SSH_PUBKEY}
 	@${UNPRIV} "echo \\\" >> $@"
 	@${UNPRIV} "echo } >> $@"
 	@${UNPRIV} "echo repository gotsys { >> $@"
+	@${UNPRIV} "echo \ \ \ \ hash algorithm ${GOT_TEST_ALGO} >> $@"
 	@${UNPRIV} "echo \ \ \ \ permit rw ${GOTSYSD_TEST_USER} >> $@"
 	@${UNPRIV} "echo } >> $@"
 
@@ -278,7 +281,7 @@ setup_test_vm: start_test_vm build_got ${GOTD_CONF} ${
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} rcctl restart syslogd"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} mkdir -m 750 /git "; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
-		got init /git/${GOTSYS_REPO}"; \
+		got init -A ${GOT_TEST_ALGO} /git/${GOTSYS_REPO}"; \
 	${UNPRIV} "${GOTSYSD_SCP_CMD} \
 		${GOT_CONF} root@$${VMIP}:/git/${GOTSYS_REPO}/got.conf"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} mkdir /tmp/gotsys "; \
@@ -342,9 +345,9 @@ test_gotwebd:
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
 		'rm -rf /git/${GOTSYS_REPO} /git/{foo,hidden}.git /tmp/gotsys'"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
-		got init /git/${GOTSYS_REPO}"; \
+		got init -A ${GOT_TEST_ALGO} /git/${GOTSYS_REPO}"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
-		got init /git/hidden.git"; \
+		got init -A ${GOT_TEST_ALGO} /git/hidden.git"; \
 	${UNPRIV} "${GOTSYSD_SCP_CMD} \
 		${GOT_CONF} root@$${VMIP}:/git/${GOTSYS_REPO}/got.conf"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} mkdir /tmp/gotsys "; \
@@ -369,7 +372,7 @@ test_gotwebd_www:
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
 		'rm -rf /git/*.git /tmp/gotsys'"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
-		got init /git/${GOTSYS_REPO}"; \
+		got init -A ${GOT_TEST_ALGO} /git/${GOTSYS_REPO}"; \
 	${UNPRIV} "${GOTSYSD_SCP_CMD} \
 		${GOT_CONF} root@$${VMIP}:/git/${GOTSYS_REPO}/got.conf"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} mkdir /tmp/gotsys "; \
@@ -395,7 +398,7 @@ test_gotwebd_repos_www:
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
 		'rm -rf /git/*.git /tmp/gotsys'"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} \
-		got init /git/${GOTSYS_REPO}"; \
+		got init -A ${GOT_TEST_ALGO} /git/${GOTSYS_REPO}"; \
 	${UNPRIV} "${GOTSYSD_SCP_CMD} \
 		${GOT_CONF} root@$${VMIP}:/git/${GOTSYS_REPO}/got.conf"; \
 	${UNPRIV} "${GOTSYSD_SSH_CMD} root@$${VMIP} mkdir /tmp/gotsys "; \
blob - a5bf50ec1fb6490b6124db124e7dffa89ee0d025be02fb3649b9ebdb32ddb60a
blob + 82ffff997c4adc36877b804c4f07dc79a325ee93bc7c17641070314c7e05409c
--- regress/gotsysd/README	
+++ regress/gotsysd/README	
@@ -54,5 +54,9 @@ Now the actual test suite can be run with:
 
   # make
 
+To run the test suite with SHA256 repositories, use:
+
+  # make GOT_TEST_ALGO=sha256
+
 A test VM will be started automatically and stopped again once the tests
 have finished running.
blob - 2954ae3d2686f64264ae771c3611a1bf8f3fd3f38cefe69239f9e8e1e36332d9
blob + 0ac6f44a8030382775f15decacec74cc2bad79cd5d6a7062350f76ed328de08c
--- regress/gotsysd/test_gotsysd.sh	
+++ regress/gotsysd/test_gotsysd.sh	
@@ -45,6 +45,7 @@ user deleteme {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -310,6 +311,7 @@ user deleteme {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -400,6 +402,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -565,6 +568,7 @@ user ${GOTSYSD_DEV_USER} {
 	group developers
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -729,6 +733,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -897,10 +902,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 EOF
@@ -979,7 +986,7 @@ EOF
 	fi
 
 	# We should be able to import data into the newly created repository.
-	got init $testroot/foo.git
+	got init -A ${GOT_TEST_ALGO} $testroot/foo.git
 	mkdir $testroot/foo
 	echo alpha > $testroot/foo/alpha
 	got import -m init -r $testroot/foo.git $testroot/foo >/dev/null
@@ -1009,6 +1016,7 @@ test_user_anonymous() {
 	# An attempt to grant write permissions to anonymous is an error.
 	cat > ${testroot}/bad-gotsys.conf <<EOF
 repository "gotsys" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw anonymous
 }
 EOF
@@ -1021,7 +1029,7 @@ EOF
 		return 1
 	fi
 
-	echo -n "gotsys: ${testroot}/bad-gotsys.conf: line 2: " \
+	echo -n "gotsys: ${testroot}/bad-gotsys.conf: line 3: " \
 		> $testroot/stderr.expected
 	echo "the \"anonymous\" user must not have write permission" \
 		>> $testroot/stderr.expected
@@ -1056,10 +1064,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 }
@@ -1132,10 +1142,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 EOF
@@ -1225,10 +1237,12 @@ looser ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 }
@@ -1309,10 +1323,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	protect branch 'mai"n'
@@ -1327,7 +1343,7 @@ EOF
 		return 1
 	fi
 
-	echo "gotsys: ${testroot}/wt/gotsys.conf: line 18: invalid reference name: refs/heads/mai\"n" \
+	echo "gotsys: ${testroot}/wt/gotsys.conf: line 20: invalid reference name: refs/heads/mai\"n" \
 		> $testroot/stderr.expected
 	cmp -s $testroot/stderr.expected $testroot/stderr
 	ret=$?
@@ -1351,8 +1367,8 @@ EOF
 	fi
 
 	cat > ${testroot}/stderr.expected <<EOF
-git-receive-pack: gotsys.conf: line 18: invalid reference name: refs/heads/mai"n
-got-send-pack: gotsys.conf: line 18: invalid reference name: refs/heads/mai"n
+git-receive-pack: gotsys.conf: line 20: invalid reference name: refs/heads/mai"n
+got-send-pack: gotsys.conf: line 20: invalid reference name: refs/heads/mai"n
 got: could not send pack file
 EOF
 	cmp -s $testroot/stderr.expected $testroot/stderr
@@ -1377,6 +1393,7 @@ user ${GOTSYSD_TEST_USER} {
 }
 
 repository "gotsys" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	head "refs/heads/foo"
 }
@@ -1391,7 +1408,7 @@ EOF
 	fi
 
 	cat > $testroot/stderr.expected <<EOF
-gotsys: ${testroot}/bad-gotsys.conf: line 8: HEAD of the "gotsys" repository cannot be overridden
+gotsys: ${testroot}/bad-gotsys.conf: line 9: HEAD of the "gotsys" repository cannot be overridden
 EOF
 	cmp -s $testroot/stderr.expected $testroot/stderr
 	ret=$?
@@ -1424,15 +1441,18 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	head foo
 }
 repository "customhead" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	head foo
@@ -1520,7 +1540,7 @@ EOF
 	fi
 
 	# Create branch "foo" in customhead.git.
-	got init -b foo $testroot/customhead.git
+	got init -A ${GOT_TEST_ALGO} -b foo $testroot/customhead.git
 	mkdir $testroot/foo
 	echo alpha > $testroot/foo/alpha
 	got import -m init -b foo -r $testroot/customhead.git \
@@ -1589,10 +1609,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	head foo
@@ -1706,10 +1728,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	deny ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	head foo
@@ -1842,10 +1866,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository "foo" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	deny ${GOTSYSD_DEV_USER}
 	permit ro anonymous
 	head foo
@@ -1855,6 +1881,7 @@ repository "foo" {
 	}
 }
 repository "bar" {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 EOF
@@ -2002,6 +2029,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 
@@ -2053,6 +2081,7 @@ user ${GOTSYSD_DEV_USER} {
 }
 
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 
@@ -2160,6 +2189,7 @@ user ${GOTSYSD_DEV_USER} {
 }
 
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 
@@ -2209,6 +2239,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 	notify url "http://${GWIP}:${GOTSYSD_TEST_HTTP_PORT}/" user flan password "password" insecure hmac "${GOTSYSD_TEST_HMAC_SECRET}"
@@ -2318,6 +2349,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 	notify email to "${GOTSYSD_TEST_USER}@example.com"
@@ -2368,6 +2400,7 @@ user ${GOTSYSD_DEV_USER} {
 }
 
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 
@@ -2465,6 +2498,7 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
blob - 5269911176f549d7dace31847685d10735427f9286fac6df40b1889d6f71d5ef
blob + b270fb5f9c49d59348aacd8eec5cad60048429c41334cab07887268941ee7c84
--- regress/gotsysd/test_gotwebd.sh	
+++ regress/gotsysd/test_gotwebd.sh	
@@ -54,16 +54,20 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository testrepo.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -152,7 +156,7 @@ EOF
 		return 1
 	fi
 
-	got init $testroot/testrepo.git
+	got init -A ${GOT_TEST_ALGO} $testroot/testrepo.git
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		"got init failed unexpectedly"
@@ -365,20 +369,25 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottest {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -560,20 +569,25 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottest.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -760,18 +774,23 @@ user ${GOTSYSD_DEV_USER} {
 	group devs
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw :writers
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw :writers
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw :devs
 }
 repository gottest.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw :testers
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw :testers
 }
 web server "${VMIP}" {
@@ -923,20 +942,25 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottest.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -995,7 +1019,7 @@ EOF
 		return 1
 	fi
 
-	got init $testroot/public.git > /dev/null
+	got init -A ${GOT_TEST_ALGO} $testroot/public.git > /dev/null
 	mkdir -p $testroot/public
 
 	cat > $testroot/public/readme.txt <<EOF
@@ -1097,20 +1121,25 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottest.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -1285,20 +1314,25 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository public.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottestdev.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository gottest.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 repository hidden.git {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
@@ -1338,7 +1372,7 @@ EOF
 		return 1
 	fi
 	cat > $testroot/stderr.expected <<EOF
-gotsys: ${testroot}/wt/gotsys.conf.bad: line 42: invalid UTF-8 string
+gotsys: ${testroot}/wt/gotsys.conf.bad: line 47: invalid UTF-8 string
 EOF
 	cmp -s $testroot/stderr.expected $testroot/stderr
 	ret=$?
@@ -1386,7 +1420,7 @@ EOF
 		return 1
 	fi
 
-	got init $testroot/public.git > /dev/null
+	got init -A ${GOT_TEST_ALGO} $testroot/public.git > /dev/null
 	mkdir -p $testroot/public
 
 	cat > $testroot/public/readme.txt <<EOF
blob - fc0028671da5dc79ca52a8b0290a47745c5dfbe95c62c0446a179652d8e89b9b
blob + 9e69a84a3bc4ffaca1bc814935881782861a38f72e509948e87fd6014c413723
--- regress/gotsysd/test_gotwebd_repos_www.sh	
+++ regress/gotsysd/test_gotwebd_repos_www.sh	
@@ -55,10 +55,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository www {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -105,7 +107,7 @@ EOF
 		return 1
 	fi
 
-	got init $testroot/www.git > /dev/null
+	got init -A ${GOT_TEST_ALGO} $testroot/www.git > /dev/null
 	mkdir -p $testroot/www
 
 	cat > $testroot/www/index.html <<EOF
blob - 63adf8d558081735aa12a9459864c179f6bd40b90bff1d872033f9f0251ee21a
blob + edd4e8587b1c123f9a3693612e515b0ea786268443c811083bb1e647ca78c261
--- regress/gotsysd/test_gotwebd_www.sh	
+++ regress/gotsysd/test_gotwebd_www.sh	
@@ -42,10 +42,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository www {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -97,7 +99,7 @@ EOF
 		return 1
 	fi
 
-	got init $testroot/www.git > /dev/null
+	got init -A ${GOT_TEST_ALGO} $testroot/www.git > /dev/null
 	mkdir -p $testroot/www
 
 	cat > $testroot/www/index.html <<EOF
@@ -209,10 +211,12 @@ user ${GOTSYSD_DEV_USER} {
 	authorized key ${sshkey}
 }
 repository gotsys {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
 repository www {
+	hash algorithm "${GOT_TEST_ALGO}"
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -263,7 +267,7 @@ EOF
 		return 1
 	fi
 
-	got init -b website $testroot/www.git > /dev/null
+	got init -A ${GOT_TEST_ALGO} -b website $testroot/www.git > /dev/null
 	mkdir -p $testroot/www
 
 	cat > $testroot/www/index.html <<EOF