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

2013-04-16 Thread Michael Haggerty
On 04/15/2013 08:15 PM, Junio C Hamano wrote:
> Thomas Ackermann  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 
>> ---
> 
> 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
mhag...@alum.mit.edu
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-04-15 Thread Junio C Hamano
Thomas Ackermann  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 
> ---

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.

>  Documentation/config.txt  |  2 +-
>  Documentation/git-cat-file.txt|  6 +++---
>  Documentation/git-describe.txt|  2 +-
>  Documentation/git-fsck.txt|  4 ++--
>  Documentation/git-index-pack.txt  |  2 +-
>  Documentation/git-ls-files.txt|  2 +-
>  Documentation/git-merge-index.txt |  2 +-
>  Documentation/git-pack-objects.txt|  2 +-
>  Documentation/git-patch-id.txt|  2 +-
>  Documentation/git-replace.txt |  4 ++--
>  Documentation/git-rev-parse.txt   |  4 ++--
>  Documentation/git-show-branch.txt |  4 ++--
>  Documentation/git-show-index.txt  |  2 +-
>  Documentation/git-show-ref.txt|  4 ++--
>  Documentation/git-tag.txt |  2 +-
>  Documentation/git-update-index.txt|  2 +-
>  Documentation/git-verify-pack.txt |  4 ++--
>  Documentation/git-verify-tag.txt  |  2 +-
>  Documentation/git.txt | 10 +-
>  Documentation/gitcore-tutorial.txt|  8 
>  Documentation/gitdiffcore.txt |  2 +-
>  Documentation/githooks.txt| 10 +-
>  Documentation/gitrepository-layout.txt|  2 +-
>  Documentation/gittutorial-2.txt   | 16 
>  Documentation/howto/recover-corrupted-blob-object.txt |  6 +++---
>  Documentation/pretty-formats.txt  |  2 +-
>  Documentation/revisions.txt   |  4 ++--
>  Documentation/technical/api-sha1-array.txt|  4 ++--
>  Documentation/technical/pack-format.txt   | 14 +++---
>  Documentation/technical/pack-heuristics.txt   |  2 +-
>  Documentation/technical/shallow.txt   |  4 ++--
>  31 files changed, 68 insertions(+), 68 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html