Re: [PATCH 02/10] hash: add a constant for the original hash algorithm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux