Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-07-30 02:14:21 +0300
committerJunio C Hamano <gitster@pobox.com>2020-07-30 19:16:49 +0300
commitb5b46d7973763cffde59425d53286faab4e4e712 (patch)
tree690a9d7d73e21502e9d94e7950e43be70b203345 /setup.c
parentc5aecfc8669b9c56fd1ba31356eedc37b7289f9c (diff)
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>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index 3a81307602..94e68bb4f4 100644
--- a/setup.c
+++ b/setup.c
@@ -470,7 +470,16 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
data->partial_clone = xstrdup(value);
} else if (!strcmp(ext, "worktreeconfig"))
data->worktree_config = git_config_bool(var, value);
- else
+ else if (!strcmp(ext, "objectformat")) {
+ int format;
+
+ if (!value)
+ return config_error_nonbool(var);
+ format = hash_algo_by_name(value);
+ if (format == GIT_HASH_UNKNOWN)
+ return error("invalid value for 'extensions.objectformat'");
+ data->hash_algo = format;
+ } else
string_list_append(&data->unknown_extensions, ext);
}
@@ -613,6 +622,11 @@ int verify_repository_format(const struct repository_format *format,
return -1;
}
+ if (format->version <= 0 && format->hash_algo != GIT_HASH_SHA1) {
+ strbuf_addstr(err, _("extensions.objectFormat is not valid in repo v0"));
+ return -1;
+ }
+
return 0;
}