Skip to content

Commit a636d39

Browse files
committed
Merge branch 'bc/use-sha256-by-default-in-3.0'
Prepare to flip the default hash function to SHA-256. * bc/use-sha256-by-default-in-3.0: Enable SHA-256 by default in breaking changes mode help: add a build option for default hash t5300: choose the built-in hash outside of a repo t4042: choose the built-in hash outside of a repo t1007: choose the built-in hash outside of a repo t: default to compile-time default hash if not set setup: use the default algorithm to initialize repo format Use legacy hash for legacy formats builtin: use default hash when outside a repository hash: add a constant for the legacy hash algorithm hash: add a constant for the default hash algorithm
2 parents 90c0775 + c79bb70 commit a636d39

25 files changed

+62
-32
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int cmd_apply(int argc,
2929
* cf. https://lore.kernel.org/git/[email protected]/
3030
*/
3131
if (!the_hash_algo)
32-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
32+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
3333

3434
argc = apply_parse_options(argc, argv,
3535
&state, &force_apply, &options,

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ int cmd_diff(int argc,
483483
* configurable via a command line option.
484484
*/
485485
if (nongit)
486-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
486+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
487487

488488
init_diff_ui_defaults();
489489
git_config(git_diff_ui_config, NULL);

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int cmd_hash_object(int argc,
104104
prefix = setup_git_directory_gently(&nongit);
105105

106106
if (nongit && !the_hash_algo)
107-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
107+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
108108

109109
if (vpath && prefix) {
110110
vpath_free = prefix_filename(prefix, vpath);

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ int cmd_index_pack(int argc,
20352035
* choice but to guess the object hash.
20362036
*/
20372037
if (!the_repository->hash_algo)
2038-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
2038+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
20392039

20402040
opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY);
20412041
if (rev_index) {

builtin/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int cmd_ls_remote(int argc,
112112
* depending on what object hash the remote uses.
113113
*/
114114
if (!the_repository->hash_algo)
115-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
115+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
116116

117117
packet_trace_identity("ls-remote");
118118

builtin/patch-id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int cmd_patch_id(int argc,
254254
* the code that computes patch IDs to always use SHA1.
255255
*/
256256
if (!the_hash_algo)
257-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
257+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
258258

259259
generate_id_list(opts ? opts > 1 : config.stable,
260260
opts ? opts == 3 : config.verbatim);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ static struct command *read_head_info(struct packet_reader *reader,
22032203
use_push_options = 1;
22042204
hash = parse_feature_value(feature_list, "object-format", &len, NULL);
22052205
if (!hash) {
2206-
hash = hash_algos[GIT_HASH_SHA1].name;
2206+
hash = hash_algos[GIT_HASH_SHA1_LEGACY].name;
22072207
len = strlen(hash);
22082208
}
22092209
if (xstrncmpz(the_hash_algo->name, hash, len))

builtin/shortlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int cmd_shortlog(int argc,
419419
* git/nongit so that we do not have to do this.
420420
*/
421421
if (nongit && !the_hash_algo)
422-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
422+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
423423

424424
git_config(git_default_config, NULL);
425425
shortlog_init(&log);

builtin/show-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int cmd_show_index(int argc,
4747
* the index file passed in and use that instead.
4848
*/
4949
if (!the_hash_algo)
50-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
50+
repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
5151

5252
hashsz = the_hash_algo->rawsz;
5353

bundle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int read_bundle_header_fd(int fd, struct bundle_header *header,
9595
* by an "object-format=" capability, which is being handled in
9696
* `parse_capability()`.
9797
*/
98-
header->hash_algo = &hash_algos[GIT_HASH_SHA1];
98+
header->hash_algo = &hash_algos[GIT_HASH_SHA1_LEGACY];
9999

100100
/* The bundle header ends with an empty line */
101101
while (!strbuf_getwholeline_fd(&buf, fd, '\n') &&
@@ -507,7 +507,7 @@ int create_bundle(struct repository *r, const char *path,
507507
* SHA1.
508508
* 2. @filter is required because we parsed an object filter.
509509
*/
510-
if (the_hash_algo != &hash_algos[GIT_HASH_SHA1] || revs.filter.choice)
510+
if (the_hash_algo != &hash_algos[GIT_HASH_SHA1_LEGACY] || revs.filter.choice)
511511
min_version = 3;
512512

513513
if (argc > 1) {

0 commit comments

Comments
 (0)