From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Typesafer git hash patch
Date: Tue, 28 Feb 2017 20:45:29 +0000 [thread overview]
Message-ID: <20170228204528.glpmouvcx33zma65@genre.crustytoothpaste.net> (raw)
In-Reply-To: <CA+55aFzUhWinWqK30GBc1BKy-v6QtDdO2BLUODkiqg9XoKLrwA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2268 bytes --]
On Tue, Feb 28, 2017 at 12:25:20PM -0800, Linus Torvalds wrote:
> On Tue, Feb 28, 2017 at 11:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
> > Sorry, but at this point in your description, you completely lost
> > me. I thought "struct object_id" was what you call "hash_t" in the
> > above.
>
> So what happened was that I started out just encapsulating
>
> unsigned char sha1[20];
>
> as a
>
> hash_t hash;
>
> and that made sense in a lot of situations. I always thought that code that used
>
> struct object_id oid;
>
> is just too ugly to live, so I'm not actually all that big of a fan of
> the oid approach.
There was some discussion on the list about the best name to use, and
object_id seemed like the most popular decision. I don't care if we add
a typedef for it and prefer that typedef, but the existing code avoided
typedefs in favor of explicit struct definitions.
I'm certainly not opposed to having less to type, because “object_id” is
awkward to type, but I've generally tried to defer to existing uses in
the codebase and what list regulars are comfortable with.
The only problem with using hash_t is that it's then not obvious as we
transition (assuming we don't take an omnibus patch) what is converted
and what isn't.
> But the two approaches really are pretty much equivalent logically,
> even if they don't look the same.
Yeah, I think they are.
> So I wanted to unify things: "One type to bring them all and in the
> darkness bind them".
>
> So I just basically made this:
>
> typedef struct object_id {
> unsigned char hash[GIT_HASH_SIZE];
> } hash_t;
>
> to create one single data structure that doesn't make my eyes bleed.
> That "struct object_id" still exists, but I don't generally have to
> look at it when doing the conversion, and any current users "just
> work".
There is nothing that prevents us from doing a nice global
search-and-replace in the future if we think the status quo is bad.
That's something that could be automated with Coccinelle.
--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]
next prev parent reply other threads:[~2017-02-28 20:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 6:59 Typesafer git hash patch Linus Torvalds
[not found] ` <xmqqvarujdmv.fsf@gitster.mtv.corp.google.com>
2017-02-28 20:19 ` brian m. carlson
2017-02-28 20:38 ` Linus Torvalds
2017-02-28 20:25 ` Linus Torvalds
2017-02-28 20:45 ` brian m. carlson [this message]
2017-02-28 20:26 ` Jeff King
2017-02-28 20:33 ` brian m. carlson
2017-02-28 20:37 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170228204528.glpmouvcx33zma65@genre.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=torvalds@linux-foundation.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).