commit ef3a5d525aa3e58dc124c6186d48731e5696e962 from: Stefan Sperling date: Wed Aug 07 14:16:08 2024 UTC make gotd(8) reject sha256 repositories at startup for now ok op@ commit - a5f79a896f1d163672b9b2e4c9a7064ebc4936f9 commit + ef3a5d525aa3e58dc124c6186d48731e5696e962 blob - e087575f78236937985aeb124917d2ff9962a9de blob + 4d75296b687289f7e3ab2a674a5ad53b3b7c8601 --- gotd/gotd.c +++ gotd/gotd.c @@ -2092,7 +2092,31 @@ main(int argc, char **argv) if (pw->pw_uid == 0) fatalx("cannot run %s as the superuser", getprogname()); + + /* + * SHA2 repositories cannot be used with gotd until Git protocol v2 + * support is added. Reject them at startup for now. + */ + TAILQ_FOREACH(repo, &gotd.repos, entry) { + struct got_repository *r; + + error = got_repo_open(&r, repo->path, NULL, NULL); + if (error) { + if (error->code == GOT_ERR_ERRNO && errno == ENOENT) + continue; + fatalx("%s: %s", repo->path, error->msg); + } + if (got_repo_get_object_format(r) != GOT_HASH_SHA1) { + error = got_error_msg(GOT_ERR_NOT_IMPL, + "sha256 object IDs unsupported in network " + "protocol"); + fatalx("%s: %s", repo->path, error->msg); + } + + got_repo_close(r); + } + if (noaction) { fprintf(stderr, "configuration OK\n"); return 0; blob - 10b2b156100b2de5d6fa3f09483b5ac4658b3074 blob + 9f370db70d268838b93dbe6d96b498def97df472 --- lib/read_gitconfig.c +++ lib/read_gitconfig.c @@ -111,13 +111,8 @@ got_repo_read_gitconfig(int *gitconfig_repository_form tags = got_gitconfig_get_tag_list(gitconfig, "extensions"); if (extnames && extvals && nextensions && tags) { size_t numext = 0; - TAILQ_FOREACH(node, &tags->fields, link) { - char *ext = node->field; - char *val = got_gitconfig_get_str(gitconfig, - "extensions", ext); - if (get_boolean_val(val)) - numext++; - } + TAILQ_FOREACH(node, &tags->fields, link) + numext++; *extnames = calloc(numext, sizeof(char *)); if (*extnames == NULL) { err = got_error_from_errno("calloc"); @@ -132,23 +127,21 @@ got_repo_read_gitconfig(int *gitconfig_repository_form char *ext = node->field; char *val = got_gitconfig_get_str(gitconfig, "extensions", ext); - if (get_boolean_val(val)) { - char *extstr = NULL, *valstr = NULL; + char *extstr = NULL, *valstr = NULL; - extstr = strdup(ext); - if (extstr == NULL) { - err = got_error_from_errno("strdup"); - goto done; - } - valstr = strdup(val); - if (valstr == NULL) { - err = got_error_from_errno("strdup"); - goto done; - } - (*extnames)[(*nextensions)] = extstr; - (*extvals)[(*nextensions)] = valstr; - (*nextensions)++; + extstr = strdup(ext); + if (extstr == NULL) { + err = got_error_from_errno("strdup"); + goto done; } + valstr = strdup(val); + if (valstr == NULL) { + err = got_error_from_errno("strdup"); + goto done; + } + (*extnames)[(*nextensions)] = extstr; + (*extvals)[(*nextensions)] = valstr; + (*nextensions)++; } } blob - 8e364cdc52ed8662ae2562398c885d5a21c3061b blob + 688ca609f943549450332e25c6e5531c66a3b239 --- regress/gotd/prepare_test_repo.sh +++ regress/gotd/prepare_test_repo.sh @@ -21,7 +21,7 @@ make_repo() local repo_path="$1" local no_tree="$2" - gotadmin init "${repo_path}" + gotadmin init -A "$GOT_TEST_ALGO" "${repo_path}" if [ -n "$no_tree" ]; then return