"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes: > 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. Nicely explained and this step shows why having GIT_HASH_DEFAULT makes sense very well. > > Signed-off-by: brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx> > --- > builtin/apply.c | 2 +- > builtin/diff.c | 2 +- > builtin/hash-object.c | 2 +- > builtin/index-pack.c | 2 +- > builtin/ls-remote.c | 2 +- > builtin/patch-id.c | 2 +- > builtin/shortlog.c | 2 +- > 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 c6231edce4..eebffe36cc 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 fe15e11497..60adc5e7a5 100644 > --- a/builtin/shortlog.c > +++ b/builtin/shortlog.c > @@ -419,7 +419,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; >