diff options
| author | brian m. carlson <sandals@crustytoothpaste.net> | 2025-07-01 21:22:29 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-01 14:58:24 -0700 |
| commit | dc9c16c2fc8222364277696cb4d70782281d3c06 (patch) | |
| tree | a0f7dc4e04712c34e961b7b6a354c57be86d7a74 | |
| parent | hash: add a constant for the legacy hash algorithm (diff) | |
| download | git-dc9c16c2fc8222364277696cb4d70782281d3c06.tar.gz git-dc9c16c2fc8222364277696cb4d70782281d3c06.zip | |
builtin: use default hash when outside a repository
We have some commands that can operate inside or outside a repository.
If we're operating outside a repository, we clearly cannot use the
repository's hash algorithm as a default since it doesn't exist, so
instead, let's pick the default instead of specifically SHA-1. Right
now this results in no functional change since the default is SHA-1, but
that may change in the future.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | builtin/apply.c | 2 | ||||
| -rw-r--r-- | builtin/diff.c | 2 | ||||
| -rw-r--r-- | builtin/hash-object.c | 2 | ||||
| -rw-r--r-- | builtin/index-pack.c | 2 | ||||
| -rw-r--r-- | builtin/ls-remote.c | 2 | ||||
| -rw-r--r-- | builtin/patch-id.c | 2 | ||||
| -rw-r--r-- | builtin/shortlog.c | 2 | ||||
| -rw-r--r-- | builtin/show-index.c | 2 |
8 files changed, 8 insertions, 8 deletions
diff --git a/builtin/apply.c b/builtin/apply.c index a1e20c593d..d642a40251 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -29,7 +29,7 @@ int cmd_apply(int argc, * cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/ */ if (!the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); argc = apply_parse_options(argc, argv, &state, &force_apply, &options, diff --git a/builtin/diff.c b/builtin/diff.c index fa963808c3..357702df9e 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -483,7 +483,7 @@ int cmd_diff(int argc, * configurable via a command line option. */ if (nongit) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); init_diff_ui_defaults(); git_config(git_diff_ui_config, NULL); diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 6a99ec250d..213a302e05 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -104,7 +104,7 @@ int cmd_hash_object(int argc, prefix = setup_git_directory_gently(&nongit); if (nongit && !the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); if (vpath && prefix) { vpath_free = prefix_filename(prefix, vpath); diff --git a/builtin/index-pack.c b/builtin/index-pack.c index bb7925bd29..352ce7f88a 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -2034,7 +2034,7 @@ int cmd_index_pack(int argc, * choice but to guess the object hash. */ if (!the_repository->hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY); if (rev_index) { diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 01a4d4daa1..df09000b30 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -112,7 +112,7 @@ int cmd_ls_remote(int argc, * depending on what object hash the remote uses. */ if (!the_repository->hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); packet_trace_identity("ls-remote"); diff --git a/builtin/patch-id.c b/builtin/patch-id.c index cdef2ec10a..26f04b0335 100644 --- a/builtin/patch-id.c +++ b/builtin/patch-id.c @@ -254,7 +254,7 @@ int cmd_patch_id(int argc, * the code that computes patch IDs to always use SHA1. */ if (!the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); generate_id_list(opts ? opts > 1 : config.stable, opts ? opts == 3 : config.verbatim); diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 30075b67be..795a631625 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -418,7 +418,7 @@ int cmd_shortlog(int argc, * git/nongit so that we do not have to do this. */ if (nongit && !the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); git_config(git_default_config, NULL); shortlog_init(&log); diff --git a/builtin/show-index.c b/builtin/show-index.c index 9d4ecf5e7b..2c3e2940ce 100644 --- a/builtin/show-index.c +++ b/builtin/show-index.c @@ -47,7 +47,7 @@ int cmd_show_index(int argc, * the index file passed in and use that instead. */ if (!the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); hashsz = the_hash_algo->rawsz; |
