git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Jonathan Nieder <jrnieder@gmail.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org
Subject: Re: Refactoring hardcoded SHA-1 constants
Date: Sat, 19 Apr 2014 02:06:27 +0200	[thread overview]
Message-ID: <5351BE03.2070604@alum.mit.edu> (raw)
In-Reply-To: <20140418224049.GA15516@google.com>

> brian m. carlson wrote:
>> I'd like to introduce a set of preprocessor constants that we'd use
>> instead of hard-coded 20s and 40s everywhere.

I agree that it would help code clarity to have symbolic constants for
these numbers.

On 04/19/2014 12:40 AM, Jonathan Nieder wrote:
> Lukewarm on that.  It's hard to do consistently and unless they're
> named well it can be harder to know what something like
> BINARY_OBJECT_NAME_LENGTH means than plain '20' when first reading.

OK, so let's see if we can name them well.  (Though I think if the names
come into wide use then we'll get familiar with them quickly.)

libgit2 seems to use the name "oid" (for "object ID") where we tend to
use "sha1" or "name".  That might be a good convention for us to move
towards.

Their constants are called GIT_OID_RAWSZ (== 20) and GIT_OID_HEXSZ (==
40).  They don't exactly roll off the tongue, I'll admit.

We wouldn't need a "GIT_" prefix, I think, since our code is not meant
to be used as a library.

Let the brainstorming (and bikeshedding) begin!

1. GIT_OID_RAWSZ / GIT_OID_HEXSZ

2. OID_RAWSZ / OID_HEXSZ

3. OID_BINARY_LEN / OID_ASCII_LEN

4. BINARY_OID_LEN / ASCII_OID_LEN

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

  reply	other threads:[~2014-04-19  0:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18 22:18 Refactoring hardcoded SHA-1 constants brian m. carlson
2014-04-18 22:40 ` Jonathan Nieder
2014-04-19  0:06   ` Michael Haggerty [this message]
2014-04-19  0:48     ` Duy Nguyen
2014-04-19  1:06       ` Junio C Hamano
2014-04-19  1:12         ` Duy Nguyen

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=5351BE03.2070604@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).