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 02/10] hash: add a constant for the original hash algorithm
Date: Thu, 19 Jun 2025 18:56:02 -0700 [thread overview]
Message-ID: <xmqq1prf89cd.fsf@gitster.g> (raw)
In-Reply-To: <20250620011943.586596-3-sandals@crustytoothpaste.net> (brian m. carlson's message of "Fri, 20 Jun 2025 01:19:34 +0000")
"brian m. carlson" <sandals@crustytoothpaste•net> writes:
> We have a a variety of uses of GIT_HASH_SHA1 littered throughout our
> code. Some of these really mean to represent specifically SHA-1, but
> some actually represent the original hash algorithm used in Git which is
> implied by older formats and protocols which do not contain hash
> information. For instance, the bundle v1 and v2 formats do not contain
> hash algorithm information, and thus SHA-1 is implied by the use of
> these formats.
Does that mean use of _ORIGINAL is a sign that these places should
keep using SHA-1 and should not change?
I am having a hard time guessing/assessing the value of having _ORIGINAL
that is a synonym for _SHA1; with redirection, it pretends as if the
underlying value can be updated from SHA-1 to SHA-256 (and that is
the very intention behind GIT_HASH_DEFAULT symbol that gives us a
level of indirection), but it is hard to imagine we would ever want
to change what _ORIGINAL means, as that word talks about a historical
fact that will never change over time.
> Add a constant for documentary purposes which indicates this value. It
> will always be the same as SHA-1, since this is an essential part of
> these formats, but its use indicates this particular reason and not any
> other reason why SHA-1 might be used.
I am not sure what this means. If we use GIT_HASH_SHA1 in such
places explicitly (as opposed to GIT_HASH_DEFAULT), isn't it a sign
enough that with different versions of Git, that particular code
path should keep using SHA-1 no matter what the default is?
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste•net>
> ---
> hash.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hash.h b/hash.h
> index 0d3d85e04c..0e14cade4e 100644
> --- a/hash.h
> +++ b/hash.h
> @@ -176,6 +176,8 @@ static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *s
> #define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
> /* Default hash algorithm if unspecified. */
> #define GIT_HASH_DEFAULT GIT_HASH_SHA1
> +/* Original hash algorithm. Implied for older data formats which don't specify. */
> +#define GIT_HASH_ORIGINAL GIT_HASH_SHA1
>
> /* "sha1", big-endian */
> #define GIT_SHA1_FORMAT_ID 0x73686131
next prev parent reply other threads:[~2025-06-20 1:56 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 [this message]
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
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=xmqq1prf89cd.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