Skip to content

Commit b5b46d7

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c5aecfc commit b5b46d7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

setup.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,16 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
470470
data->partial_clone = xstrdup(value);
471471
} else if (!strcmp(ext, "worktreeconfig"))
472472
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
474483
string_list_append(&data->unknown_extensions, ext);
475484
}
476485

@@ -613,6 +622,11 @@ int verify_repository_format(const struct repository_format *format,
613622
return -1;
614623
}
615624

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+
616630
return 0;
617631
}
618632

0 commit comments

Comments
 (0)