]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'bc/sha-256-part-3'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2020 01:04:11 +0000 (18:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2020 01:04:11 +0000 (18:04 -0700)
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
  ...

15 files changed:
1  2 
builtin/bundle.c
builtin/verify-pack.c
bundle.c
bundle.h
setup.c
t/t0000-basic.sh
t/t1450-fsck.sh
t/t5300-pack-object.sh
t/t5318-commit-graph.sh
t/t5324-split-commit-graph.sh
t/t5510-fetch.sh
t/t8002-blame.sh
t/t9700/test.pl
t/test-lib-functions.sh
t/test-lib.sh

index 750630bdd94831e9cd746c2d62aef0bb3a060a2d,e1a85e7dcc0380beb2cd09fefb2ab3e9e4f23fe2..ea6948110b0fc933c81585a33b67a1121acde35b
@@@ -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,
index c2a1a5c5048412abaa545862dbd0f3dd93338dc5,3669a90263678757e08897a47f13bd5a797f25e7..05c52135946b77ba6014f69b203d3e979df94ffd
@@@ -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 7ef9c3a7c387e140f5d5bbdb43d832ab2dbf7c71,35585f237c73575dfbae786c900236c8f1badeb1..995a940dfd65864bb88251d486f37d67ddae728e
+++ b/bundle.c
  #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 3f5c9ad2204ab831a71ac138d72382a480f4c2a9,70c84cab08a12a11606666221bb14eff634f5a2f..f9e2d1c8ef544d39e440656aa59d21c62e919777
+++ 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 78e7ae1be76be872f45f5e9a91402ce0335c33f6,94e68bb4f48efc5707f0358a35d28c3d84f5c4fd..c04cd25a30dfe0e97d93087c0e7f29910d1b46a5
+++ 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;
Simple merge
diff --cc t/t1450-fsck.sh
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc t/t9700/test.pl
Simple merge
Simple merge
diff --cc t/test-lib.sh
index ba224c86f5e9988a7294c30260d9ef7590681e25,0483ed51e16079047b0e8f99d9a3602ce9141d98..ef31f400374755015ccec300bdb450021aeccc17
@@@ -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 <timestamp> <file>:<line> output
  GIT_TRACE_BARE=1
  export GIT_TRACE_BARE