From: Junio C Hamano Date: Wed, 12 Aug 2020 01:04:11 +0000 (-0700) Subject: Merge branch 'bc/sha-256-part-3' X-Git-Tag: v2.29.0-rc0~178 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e0ad9574ddf5bb14d9ed6808112485ce0da99fea;p=thirdparty%2Fgit.git Merge branch 'bc/sha-256-part-3' The final leg of SHA-256 transition. * bc/sha-256-part-3: (39 commits) t: remove test_oid_init in tests docs: add documentation for extensions.objectFormat ci: run tests with SHA-256 t: make SHA1 prerequisite depend on default hash t: allow testing different hash algorithms via environment t: add test_oid option to select hash algorithm repository: enable SHA-256 support by default setup: add support for reading extensions.objectformat bundle: add new version for use with SHA-256 builtin/verify-pack: implement an --object-format option http-fetch: set up git directory before parsing pack hashes t0410: mark test with SHA1 prerequisite t5308: make test work with SHA-256 t9700: make hash size independent t9500: ensure that algorithm info is preserved in config t9350: make hash size independent t9301: make hash size independent t9300: use $ZERO_OID instead of hard-coded object ID t9300: abstract away SHA-1-specific constants t8011: make hash size independent ... --- e0ad9574ddf5bb14d9ed6808112485ce0da99fea diff --cc builtin/bundle.c index 750630bdd9,e1a85e7dcc..ea6948110b --- a/builtin/bundle.c +++ b/builtin/bundle.c @@@ -59,7 -59,8 +59,8 @@@ static int parse_options_cmd_bundle(in static int cmd_bundle_create(int argc, const char **argv, const char *prefix) { int all_progress_implied = 0; int progress = isatty(STDERR_FILENO); - struct argv_array pack_opts; + struct strvec pack_opts; + int version = -1; struct option options[] = { OPT_SET_INT('q', "quiet", &progress, diff --cc builtin/verify-pack.c index c2a1a5c504,3669a90263..05c5213594 --- a/builtin/verify-pack.c +++ b/builtin/verify-pack.c @@@ -7,21 -7,26 +7,26 @@@ #define VERIFY_PACK_VERBOSE 01 #define VERIFY_PACK_STAT_ONLY 02 - static int verify_one_pack(const char *path, unsigned int flags) + static int verify_one_pack(const char *path, unsigned int flags, const char *hash_algo) { struct child_process index_pack = CHILD_PROCESS_INIT; - const char *argv[] = {"index-pack", NULL, NULL, NULL }; - struct argv_array *argv = &index_pack.args; ++ struct strvec *argv = &index_pack.args; struct strbuf arg = STRBUF_INIT; int verbose = flags & VERIFY_PACK_VERBOSE; int stat_only = flags & VERIFY_PACK_STAT_ONLY; int err; - argv_array_push(argv, "index-pack"); ++ strvec_push(argv, "index-pack"); + if (stat_only) - argv[1] = "--verify-stat-only"; - argv_array_push(argv, "--verify-stat-only"); ++ strvec_push(argv, "--verify-stat-only"); else if (verbose) - argv[1] = "--verify-stat"; - argv_array_push(argv, "--verify-stat"); ++ strvec_push(argv, "--verify-stat"); else - argv[1] = "--verify"; - argv_array_push(argv, "--verify"); ++ strvec_push(argv, "--verify"); + + if (hash_algo) - argv_array_pushf(argv, "--object-format=%s", hash_algo); ++ strvec_pushf(argv, "--object-format=%s", hash_algo); /* * In addition to "foo.pack" we accept "foo.idx" and "foo"; @@@ -31,9 -36,8 +36,8 @@@ if (strbuf_strip_suffix(&arg, ".idx") || !ends_with(arg.buf, ".pack")) strbuf_addstr(&arg, ".pack"); - argv[2] = arg.buf; - argv_array_push(argv, arg.buf); ++ strvec_push(argv, arg.buf); - index_pack.argv = argv; index_pack.git_cmd = 1; err = run_command(&index_pack); diff --cc bundle.c index 7ef9c3a7c3,35585f237c..995a940dfd --- a/bundle.c +++ b/bundle.c @@@ -10,9 -10,18 +10,18 @@@ #include "list-objects.h" #include "run-command.h" #include "refs.h" -#include "argv-array.h" +#include "strvec.h" - static const char bundle_signature[] = "# v2 git bundle\n"; + + static const char v2_bundle_signature[] = "# v2 git bundle\n"; + static const char v3_bundle_signature[] = "# v3 git bundle\n"; + static struct { + int version; + const char *signature; + } bundle_sigs[] = { + { 2, v2_bundle_signature }, + { 3, v3_bundle_signature }, + }; static void add_to_ref_list(const struct object_id *oid, const char *name, struct ref_list *list) @@@ -449,7 -475,7 +475,7 @@@ static int write_bundle_refs(int bundle } int create_bundle(struct repository *r, const char *path, - int argc, const char **argv, struct strvec *pack_options) - int argc, const char **argv, struct argv_array *pack_options, int version) ++ int argc, const char **argv, struct strvec *pack_options, int version) { struct lock_file lock = LOCK_INIT; int bundle_fd = -1; diff --cc bundle.h index 3f5c9ad220,70c84cab08..f9e2d1c8ef --- a/bundle.h +++ b/bundle.h @@@ -21,7 -22,8 +22,8 @@@ struct bundle_header int is_bundle(const char *path, int quiet); int read_bundle_header(const char *path, struct bundle_header *header); int create_bundle(struct repository *r, const char *path, - int argc, const char **argv, struct strvec *pack_options); - int argc, const char **argv, struct argv_array *pack_options, ++ int argc, const char **argv, struct strvec *pack_options, + int version); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); #define BUNDLE_VERBOSE 1 int unbundle(struct repository *r, struct bundle_header *header, diff --cc setup.c index 78e7ae1be7,94e68bb4f4..c04cd25a30 --- a/setup.c +++ b/setup.c @@@ -447,54 -447,6 +447,63 @@@ static int read_worktree_config(const c return 0; } +enum extension_result { + EXTENSION_ERROR = -1, /* compatible with error(), etc */ + EXTENSION_UNKNOWN = 0, + EXTENSION_OK = 1 +}; + +/* + * Do not add new extensions to this function. It handles extensions which are + * respected even in v0-format repositories for historical compatibility. + */ +static enum extension_result handle_extension_v0(const char *var, + const char *value, + const char *ext, + struct repository_format *data) +{ + if (!strcmp(ext, "noop")) { + return EXTENSION_OK; + } else if (!strcmp(ext, "preciousobjects")) { + data->precious_objects = git_config_bool(var, value); + return EXTENSION_OK; + } else if (!strcmp(ext, "partialclone")) { + if (!value) + return config_error_nonbool(var); + data->partial_clone = xstrdup(value); + return EXTENSION_OK; + } else if (!strcmp(ext, "worktreeconfig")) { + data->worktree_config = git_config_bool(var, value); + return EXTENSION_OK; + } + + return EXTENSION_UNKNOWN; +} + +/* + * Record any new extensions in this function. + */ +static enum extension_result handle_extension(const char *var, + const char *value, + const char *ext, + struct repository_format *data) +{ + if (!strcmp(ext, "noop-v1")) { + return EXTENSION_OK; - } ++ } 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; ++ return EXTENSION_OK; ++ } + return EXTENSION_UNKNOWN; +} + static int check_repo_format(const char *var, const char *value, void *vdata) { struct repository_format *data = vdata; diff --cc t/test-lib.sh index ba224c86f5,0483ed51e1..ef31f40037 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@@ -452,9 -450,11 +452,12 @@@ GIT_MERGE_AUTOEDIT=n export GIT_MERGE_VERBOSITY GIT_MERGE_AUTOEDIT export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME +export GIT_COMMITTER_DATE GIT_AUTHOR_DATE export EDITOR + GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}" + export GIT_DEFAULT_HASH + # Tests using GIT_TRACE typically don't want : output GIT_TRACE_BARE=1 export GIT_TRACE_BARE