Download raw body.
allow changing default hash algorithm in gotsys.conf
Makes life a bit simpler for people who really don't want to jump
onto the Git SHA256 train just yet.
ok?
M gotsys/gotsys.conf.5 | 18+ 1-
M gotsys/gotsys.h | 1+ 0-
M gotsys/parse.y | 28+ 0-
M lib/gotsys_conf.c | 3+ 1-
4 files changed, 50 insertions(+), 2 deletions(-)
commit - fc83c481c4940f4ac250a21c4dac396a9f60bb78
commit + c99905d093df810ae083b6382b24bf1be150c9ba
blob - 334eba2c3537abef7debd35788f38e98533a240d
blob + b19d6037dc09a70f981cebbf89b8a9e3281224d1
--- gotsys/gotsys.conf.5
+++ gotsys/gotsys.conf.5
@@ -43,6 +43,21 @@ are treated as comments and ignored.
.Sh GLOBAL CONFIGURATION
The available global configuration directives are as follows:
.Bl -tag -width Ds
+.It Ic hash algorithm Ar hashing-algorithm
+Configure the default
+.Ar hashing-algorithm
+used for the computation of Git object IDs.
+Possible values are
+.Dq sha256
+.Pq the default
+or
+.Dq sha1 .
+.Pp
+This configuration directive only affects newly created repositories.
+The hashing algorithm of existing repositories cannot be changed.
+.Pp
+The default hash algorithm can be overridden with per-repository
+configuration directives described below.
.It Ic group Ar name
Declare a group with the given
.Ar name .
@@ -296,9 +311,11 @@ Configure the repository's
used for the computation of Git object IDs.
Possible values are
.Dq sha256
-.Pq the default
or
.Dq sha1 .
+If not set, the value set in the global configuration context will be used,
+which defaults to
+.Dq sha256 .
.Pp
This configuration directive only affects newly created repositories.
The hashing algorithm of existing repositories cannot be changed.
blob - c2049433c8393df1affc57a5d92371e126268a7d
blob + ce6c5d7b0d41bd2c926d1d2ccee55ebd84003dc3
--- gotsys/gotsys.h
+++ gotsys/gotsys.h
@@ -172,6 +172,7 @@ struct gotsys_conf {
int nrepos;
struct gotsys_webserverlist webservers;
struct mediatypes mediatypes;
+ enum got_hash_algorithm default_algo;
};
void gotsys_conf_init(struct gotsys_conf *);
blob - 06a5f4c11720b289740d52fe2c60a9cc64c63cf4
blob + 507cefc9d463914e9cccf75897586e9e1b8f297e
--- gotsys/parse.y
+++ gotsys/parse.y
@@ -238,6 +238,27 @@ main : USER STRING {
| MEDIA TYPES '{' optnl mediaopts_l '}' {
new_mediatypes = &gotsysconf->mediatypes;
}
+ | HASH ALGORITHM STRING {
+ const struct got_error *err;
+ enum got_hash_algorithm algo;
+
+ err = gotsys_conf_validate_hash_algo(&algo, $3);
+ if (err) {
+ yyerror("%s", err->msg);
+ free($3);
+ YYERROR;
+ }
+
+ if (gotsysconf->default_algo != GOT_NUM_HASH_ALGOS) {
+ yyerror("the default hash algorithm can only "
+ "be specified once");
+ free($3);
+ YYERROR;
+ }
+
+ gotsysconf->default_algo = algo;
+ free($3);
+ }
;
useropts1 : GROUP STRING {
@@ -1659,6 +1680,13 @@ gotsys_conf_parse(const char *filename, struct gotsys_
"repository %s.git", GOTSYS_SYSTEM_REPOSITORY_NAME);
}
+ if (gotsysconf->default_algo == GOT_NUM_HASH_ALGOS)
+ gotsysconf->default_algo = GOT_HASH_SHA256;
+ TAILQ_FOREACH(repo, &gotsysconf->repos, entry) {
+ if (repo->algo == GOT_NUM_HASH_ALGOS)
+ repo->algo = gotsysconf->default_algo;
+ }
+
STAILQ_FOREACH(srv, &gotsysconf->webservers, entry) {
struct gotsys_webrepo *webrepo;
struct gotsys_repo *repo;
blob - dbea080c327ee70d65515a0206d9eff88e8953ef
blob + 202f7991dd065f22b089bc94abec09f9aa73caed
--- lib/gotsys_conf.c
+++ lib/gotsys_conf.c
@@ -59,6 +59,8 @@ gotsys_conf_init(struct gotsys_conf *gotsysconf)
TAILQ_INIT(&gotsysconf->repos);
STAILQ_INIT(&gotsysconf->webservers);
RB_INIT(&gotsysconf->mediatypes);
+
+ gotsysconf->default_algo = GOT_NUM_HASH_ALGOS; /* unset */
}
const struct got_error *
@@ -908,7 +910,7 @@ gotsys_conf_new_repo(struct gotsys_repo **new_repo, co
"repository name too long: %s", name);
}
- repo->algo = GOT_HASH_SHA256;
+ repo->algo = GOT_NUM_HASH_ALGOS; /* unset */
*new_repo = repo;
return NULL;
allow changing default hash algorithm in gotsys.conf