public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "brian m. carlson" <sandals@crustytoothpaste•net>
Cc: <git@vger•kernel.org>,  Patrick Steinhardt <ps@pks•im>
Subject: Re: [PATCH 03/10] builtin: use default hash when outside a repository
Date: Fri, 20 Jun 2025 07:19:41 -0700	[thread overview]
Message-ID: <xmqqikkq7awy.fsf@gitster.g> (raw)
In-Reply-To: <20250620011943.586596-4-sandals@crustytoothpaste.net> (brian m. carlson's message of "Fri, 20 Jun 2025 01:19:35 +0000")

"brian m. carlson" <sandals@crustytoothpaste•net> 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@crustytoothpaste•net>
> ---
>  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;
>  

  reply	other threads:[~2025-06-20 14:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20  1:19 [PATCH 00/10] Add SHA-256 by default as a breaking change brian m. carlson
2025-06-20  1:19 ` [PATCH 01/10] hash: add a constant for the default hash algorithm brian m. carlson
2025-06-20  1:19 ` [PATCH 02/10] hash: add a constant for the original " brian m. carlson
2025-06-20  1:56   ` Junio C Hamano
2025-06-20 20:43     ` brian m. carlson
2025-07-01 11:35       ` Patrick Steinhardt
2025-06-20  1:19 ` [PATCH 03/10] builtin: use default hash when outside a repository brian m. carlson
2025-06-20 14:19   ` Junio C Hamano [this message]
2025-07-01 11:35   ` Patrick Steinhardt
2025-07-01 21:14     ` brian m. carlson
2025-07-02 15:08       ` Patrick Steinhardt
2025-06-20  1:19 ` [PATCH 04/10] Use original hash for legacy formats brian m. carlson
2025-06-20 14:26   ` Junio C Hamano
2025-06-20 20:51     ` brian m. carlson
2025-06-20 21:14       ` Junio C Hamano
2025-07-01 11:35         ` Patrick Steinhardt
2025-06-20  1:19 ` [PATCH 05/10] setup: use the default algorithm to initialize repo format brian m. carlson
2025-06-20 14:55   ` Junio C Hamano
2025-06-20 20:28     ` brian m. carlson
2025-06-20 21:05       ` Junio C Hamano
2025-06-20  1:19 ` [PATCH 06/10] t: default to compile-time default hash if not set brian m. carlson
2025-06-20  1:19 ` [PATCH 07/10] t1007: choose the built-in hash outside of a repo brian m. carlson
2025-06-20  1:19 ` [PATCH 08/10] t4042: " brian m. carlson
2025-06-20  1:19 ` [PATCH 09/10] t5300: " brian m. carlson
2025-06-20  1:19 ` [PATCH 10/10] Enable SHA-256 by default in breaking changes mode brian m. carlson
2025-06-20 14:58   ` Junio C Hamano
2025-06-20 19:18     ` brian m. carlson
2025-06-20 15:03   ` Junio C Hamano
2025-06-20 19:15     ` brian m. carlson
2025-06-20 20:42       ` Junio C Hamano
2025-06-20 21:06         ` brian m. carlson
2025-07-01 11:35   ` Patrick Steinhardt
2025-07-01 21:22 ` [PATCH v2 00/11] Add SHA-256 by default as a breaking change brian m. carlson
2025-07-01 21:22   ` [PATCH v2 01/11] hash: add a constant for the default hash algorithm brian m. carlson
2025-07-01 21:22   ` [PATCH v2 02/11] hash: add a constant for the legacy " brian m. carlson
2025-07-01 21:22   ` [PATCH v2 03/11] builtin: use default hash when outside a repository brian m. carlson
2025-07-01 21:22   ` [PATCH v2 04/11] Use legacy hash for legacy formats brian m. carlson
2025-07-01 21:22   ` [PATCH v2 05/11] setup: use the default algorithm to initialize repo format brian m. carlson
2025-07-01 21:22   ` [PATCH v2 06/11] t: default to compile-time default hash if not set brian m. carlson
2025-07-01 21:22   ` [PATCH v2 07/11] t1007: choose the built-in hash outside of a repo brian m. carlson
2025-07-01 21:22   ` [PATCH v2 08/11] t4042: " brian m. carlson
2025-07-01 21:22   ` [PATCH v2 09/11] t5300: " brian m. carlson
2025-07-01 21:22   ` [PATCH v2 10/11] help: add a build option for default hash brian m. carlson
2025-07-01 21:22   ` [PATCH v2 11/11] Enable SHA-256 by default in breaking changes mode brian m. carlson
2025-07-01 22:10   ` [PATCH v2 00/11] Add SHA-256 by default as a breaking change Junio C Hamano
2025-07-02 14:46   ` Patrick Steinhardt
2025-07-02 15:01     ` Kristoffer Haugsbakk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqikkq7awy.fsf@gitster.g \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=ps@pks$(echo .)im \
    --cc=sandals@crustytoothpaste$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox