All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thomas Ackermann <th.acker@arcor.de>, git@vger.kernel.org
Subject: Re: [PATCH v3 3/4] The name of the hash function is "SHA-1", not "SHA1"
Date: Tue, 16 Apr 2013 09:10:32 +0200	[thread overview]
Message-ID: <516CF968.7010606@alum.mit.edu> (raw)
In-Reply-To: <7vtxn7slro.fsf@alter.siamese.dyndns.org>

On 04/15/2013 08:15 PM, Junio C Hamano wrote:
> Thomas Ackermann <th.acker@arcor.de> 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@arcor.de>
>> ---
> 
> 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@alum.mit.edu
http://softwareswirl.blogspot.com/

  reply	other threads:[~2013-04-16  7:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 17:45 [PATCH v3 0/4] Some small fixes to glossary-content.txt Thomas Ackermann
2013-04-15 17:46 ` [PATCH v3 1/4] glossary: remove outdated/misleading/irrelevant entries Thomas Ackermann
2013-04-15 18:14   ` Junio C Hamano
2013-04-15 17:47 ` [PATCH v3 2/4] glossary: improve description of SHA-1 related topics Thomas Ackermann
2013-04-15 17:49 ` [PATCH v3 3/4] The name of the hash function is "SHA-1", not "SHA1" Thomas Ackermann
2013-04-15 18:15   ` Junio C Hamano
2013-04-16  7:10     ` Michael Haggerty [this message]
2013-04-15 17:50 ` [PATCH v3 4/4] glossary: improve definitions of refspec and pathspec Thomas Ackermann
2013-04-15 18:14   ` Junio C Hamano
2013-04-15 18:41     ` Aw: " Thomas Ackermann

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=516CF968.7010606@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=th.acker@arcor.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.