commit - 3093e2d747a41afd623354136331c7babea32ca8
commit + 92db087118aad2bfd84c47936530b6afcc403035
blob - f6291e8407d22bd8dea75ff94f8f7b88ebafcb78
blob + da3ccae2d248a1264070ba019dbe1c73c139be25
--- include/got_error.h
+++ include/got_error.h
#define GOT_ERR_COMMIT_BAD_AUTHOR 166
#define GOT_ERR_UID 167
#define GOT_ERR_GID 168
+#define GOT_ERR_OBJECT_FORMAT 169
struct got_error {
int code;
blob - 041a41fbd209cbb7d7131b52327e59668eea4f41
blob + b3dcf46f0677a58fcf21a1e00a9e98a3586c0126
--- lib/error.c
+++ lib/error.c
"make Git unhappy" },
{ GOT_ERR_UID, "bad user ID" },
{ GOT_ERR_GID, "bad group ID" },
+ { GOT_ERR_OBJECT_FORMAT, "object format not supported" },
};
static struct got_custom_error {
blob - b8032ffd3ffe9dab29beaf3cc57c39a6ef957859
blob + 69b8cbb93b53f21dbe2c44280bb25dc5e5c23beb
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
char *path;
char *path_git_dir;
int gitdir_fd;
+ enum got_hash_algorithm algo;
struct got_pathlist_head packidx_paths;
struct timespec pack_path_mtime;
void got_repo_unpin_pack(struct got_repository *);
const struct got_error *got_repo_read_gitconfig(int *, char **, char **,
- struct got_remote_repo **, int *, char **, char ***, int *,
+ struct got_remote_repo **, int *, char **, char **, char ***, int *,
const char *);
const struct got_error *got_repo_temp_fds_get(int *, int *,
blob - d46762d0f8fd908e9beebe23dd87ff3740db4068
blob + 69013f51eff2d0f99eaf8e936973a50f9bfe625e
--- lib/read_gitconfig.c
+++ lib/read_gitconfig.c
got_repo_read_gitconfig(int *gitconfig_repository_format_version,
char **gitconfig_author_name, char **gitconfig_author_email,
struct got_remote_repo **remotes, int *nremotes,
- char **gitconfig_owner, char ***extensions, int *nextensions,
+ char **gitconfig_owner, char **objectformat,
+ char ***extensions, int *nextensions,
const char *gitconfig_path)
{
const struct got_error *err = NULL;
(*extensions)[(*nextensions)] = extstr;
(*nextensions)++;
}
+ if (objectformat && !strcmp(val, "objectformat")) {
+ free(*objectformat);
+ *objectformat = strdup(ext);
+ if (*objectformat == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
+ }
}
}
blob - e76312afb71dc950015ded8344d412b185adb00c
blob + d281c9075f8d3df732624aadb75fcae208277105
--- lib/read_gitconfig_privsep.c
+++ lib/read_gitconfig_privsep.c
got_repo_read_gitconfig(int *gitconfig_repository_format_version,
char **gitconfig_author_name, char **gitconfig_author_email,
struct got_remote_repo **remotes, int *nremotes,
- char **gitconfig_owner, char ***extensions, int *nextensions,
+ char **gitconfig_owner, char **object_format,
+ char ***extensions, int *nextensions,
const char *gitconfig_path)
{
const struct got_error *err = NULL, *child_err = NULL;
*nremotes = 0;
if (gitconfig_owner)
*gitconfig_owner = NULL;
+ if (object_format)
+ *object_format = NULL;
fd = open(gitconfig_path, O_RDONLY | O_CLOEXEC);
if (fd == -1) {
blob - 035b7755844e1535807379a27b51c214e2352f0a
blob + 5dc87706104f9f936d06b8023afe754d3d054de1
--- lib/repository.c
+++ lib/repository.c
{
const struct got_error *err = NULL;
char *repo_gitconfig_path = NULL;
+ char *object_format = NULL;
if (global_gitconfig_path) {
/* Read settings from ~/.gitconfig. */
err = got_repo_read_gitconfig(&dummy_repo_version,
&repo->global_gitconfig_author_name,
&repo->global_gitconfig_author_email,
- NULL, NULL, NULL, NULL, NULL, global_gitconfig_path);
+ NULL, NULL, NULL, NULL, NULL, NULL, global_gitconfig_path);
if (err)
return err;
}
&repo->gitconfig_repository_format_version,
&repo->gitconfig_author_name, &repo->gitconfig_author_email,
&repo->gitconfig_remotes, &repo->ngitconfig_remotes,
- &repo->gitconfig_owner, &repo->extensions, &repo->nextensions,
+ &repo->gitconfig_owner, &object_format,
+ &repo->extensions, &repo->nextensions,
repo_gitconfig_path);
if (err)
goto done;
+
+ if (!object_format)
+ repo->algo = GOT_HASH_SHA1;
+ else {
+ if (!strcmp(object_format, "sha256"))
+ repo->algo = GOT_HASH_SHA256;
+ else {
+ err = got_error_msg(GOT_ERR_OBJECT_FORMAT,
+ object_format);
+ goto done;
+ }
+ }
if (getenv("GOT_IGNORE_GITCONFIG") != NULL) {
int i;
}
done:
+ free(object_format);
free(repo_gitconfig_path);
return err;
}
err = read_gitconfig(repo, global_gitconfig_path);
if (err)
goto done;
- if (repo->gitconfig_repository_format_version != 0) {
+ if (repo->gitconfig_repository_format_version > 1) {
err = got_error_path(path, GOT_ERR_GIT_REPO_FORMAT);
goto done;
}
+ if (repo->gitconfig_repository_format_version == 0 &&
+ repo->algo != GOT_HASH_SHA1) {
+ err = got_error(GOT_ERR_OBJECT_FORMAT);
+ goto done;
+ }
for (i = 0; i < repo->nextensions; i++) {
char *ext = repo->extensions[i];
int j, supported = 0;