Re: [PATCH v3 3/4] The name of the hash function is "SHA-1", not "SHA1"

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

 



On 04/15/2013 08:15 PM, Junio C Hamano wrote:
> Thomas Ackermann <th.acker@xxxxxxxx> writes:
> 
>> Use "SHA-1" instead of "SHA1" whenever we talk about the hash function.
>> When used as a programming symbol, we keep "SHA1".
>>
>> Signed-off-by: Thomas Ackermann <th.acker@xxxxxxxx>
>> ---
> 
> Thanks.  Will queue as-is for now, but I wonder if we want to fix
> them to more official "object name", if we are going to the trouble
> of fixing all of these.  It depends on how many places already
> correctly spell SHA-1, I guess.

I like the idea of making the Git documentation (and the source code)
more algorithm-agnostic.  But personally, I think "object name" is a bad
generic term for describing object hashes.  The word "name" suggests a
moniker that was intentionally given to the object.  I suppose that this
is a big reason that the term "SHA-1" is used so frequently rather than
"object name"--because it is transparently obvious that an "SHA-1" is a
hash as opposed to, say, a filename.

In my opinion, rather than expand the use of the term "object name", we
should pick a better official term that makes it more obvious what we
are talking about, like "object hash".

While we are at it, if being more algorithm-agnostic is considered a
worthy goal, maybe it would be helpful to establish a source code naming
convention to be used in new code in favor of "sha1"; for example,

    ohash = hash of an object of unknown type
    chash = hash of a commit object
    etc.

Obviously I'm not suggesting that Git should transition away from using
SHA-1s, just that the choice of hashing algorithm need not be quite so
explicit in source code that doesn't really need to care.

On a related topic, I find it shocking how often the hard-coded
constants "20", "40", and "41" appear in git source code:

    $ git grep -e '\<20\>' -- '*.c' '*.h' '*.sh' '*.perl' | wc -l
    689
    $ git grep -e '\<4[01]\>' -- '*.c' '*.h' '*.sh' '*.perl' | wc -l
    339

The vast majority of these have to do with the length of a SHA-1 hash.
I think it would aid source-code readability if there were named
constants for the lengths of object hashes in binary and hex format.

Michael

-- 
Michael Haggerty
mhagger@xxxxxxxxxxxx
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]