commit a62a9cd59d45e9b2d65e691529c380a6fddff4c7 from: Omar Polo date: Fri Jul 12 19:22:45 2024 UTC handle repository format version 1 and objectformat extensions commit - e5c03b5556a9c6effc6a983a9ff4a0a43709c91e commit + a62a9cd59d45e9b2d65e691529c380a6fddff4c7 blob - 43420d51963fb8796ed7148130020e3b879a4c8a blob + 8b52a98aa8b52fe2d3775b7f19516cb967ebdec3 --- include/got_error.h +++ include/got_error.h @@ -59,7 +59,7 @@ #define GOT_ERR_PACK_OFFSET 42 #define GOT_ERR_OBJ_EXISTS 43 #define GOT_ERR_BAD_OBJ_ID 44 -/* 45 is currently unused */ +#define GOT_ERR_OBJECT_FORMAT 45 #define GOT_ERR_ITER_COMPLETED 46 #define GOT_ERR_RANGE 47 #define GOT_ERR_EXPECTED 48 /* for use in regress tests only */ blob - 9bffc4e83ea4a9ea3c5f65dc26cdd5fd0d069712 blob + 2897f7222b41cd87986de117e09ca594c4bef16f --- lib/error.c +++ lib/error.c @@ -83,6 +83,7 @@ static const struct got_error got_errors[] = { { GOT_ERR_PACK_OFFSET, "bad offset in pack file" }, { GOT_ERR_OBJ_EXISTS, "object already exists" }, { GOT_ERR_BAD_OBJ_ID, "bad object id" }, + { GOT_ERR_OBJECT_FORMAT, "object format not supported" }, { GOT_ERR_ITER_COMPLETED,"iteration completed" }, { GOT_ERR_RANGE, "value out of range" }, { GOT_ERR_EXPECTED, "expected an error but have no error" }, blob - c2bffe1a9e66be605e77b82a0240a6e4bf6ac481 blob + feddab7822ac272eff0ebf1280dd08ce8e64454f --- lib/repository.c +++ lib/repository.c @@ -791,7 +791,7 @@ got_repo_open(struct got_repository **repop, const cha 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; } @@ -799,6 +799,18 @@ got_repo_open(struct got_repository **repop, const cha char *ext = repo->extnames[i]; char *val = repo->extvals[i]; int j, supported = 0; + + if (repo->gitconfig_repository_format_version == 1 && + strcasecmp(ext, "objectformat") == 0) { + if (strcmp(val, "sha1") == 0) + continue; + if (strcmp(val, "sha256") == 0) { + repo->algo = GOT_HASH_SHA256; + continue; + } + err = got_error_path(val, GOT_ERR_OBJECT_FORMAT); + goto done; + } if (!is_boolean_val(val)) { err = got_error_path(ext, GOT_ERR_GIT_REPO_EXT);