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
...
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,
#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";
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);
#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)
}
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;
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,
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;
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 <timestamp> <file>:<line> output
GIT_TRACE_BARE=1
export GIT_TRACE_BARE