@matheusbsbs / matheus-bagliano / commits / b5b46d7973
Fork 0

setup: add support for reading extensions.objectformat

The transition plan specifies extensions.objectFormat as the indication that we're using a given hash in a certain repo. Read this as one of the extensions we support. If the user has specified an invalid value, fail. Ensure that we reject the extension if the repository format version is 0. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jul 29, 2020 at 23:14 UTC b5b46d7973763cffde59425d53286faab4e4e712
1 file changed +15 -1
setup.c
+15 -1
@@ -470,7 +470,16 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
470 data->partial_clone = xstrdup(value);
471 } else if (!strcmp(ext, "worktreeconfig"))
472 data->worktree_config = git_config_bool(var, value);
473 - else
473 + else if (!strcmp(ext, "objectformat")) {
474 + int format;
475 +
476 + if (!value)
477 + return config_error_nonbool(var);
478 + format = hash_algo_by_name(value);
479 + if (format == GIT_HASH_UNKNOWN)
480 + return error("invalid value for 'extensions.objectformat'");
481 + data->hash_algo = format;
482 + } else
483 string_list_append(&data->unknown_extensions, ext);
484 }
485
@@ -613,6 +622,11 @@ int verify_repository_format(const struct repository_format *format,
622 return -1;
623 }
624
625 + if (format->version <= 0 && format->hash_algo != GIT_HASH_SHA1) {
626 + strbuf_addstr(err, _("extensions.objectFormat is not valid in repo v0"));
627 + return -1;
628 + }
629 +
630 return 0;
631 }
632