From: Junio C Hamano <gitster@pobox.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: Jeff King <peff@peff.net>, Nicolas Pitre <nico@fluxnic.net>,
git@vger.kernel.org
Subject: Re: [PATCH 2/6] replace_object: use struct members instead of an array
Date: Fri, 21 Feb 2014 10:23:40 -0800 [thread overview]
Message-ID: <xmqqeh2w495f.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1393000327-11402-3-git-send-email-mhagger@alum.mit.edu> (Michael Haggerty's message of "Fri, 21 Feb 2014 17:32:03 +0100")
Michael Haggerty <mhagger@alum.mit.edu> writes:
> Give the poor humans some names to help them make sense of things.
>
> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
Good.
Reviewed-by: me.
> replace_object.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/replace_object.c b/replace_object.c
> index cdcaf8c..6fc3ff4 100644
> --- a/replace_object.c
> +++ b/replace_object.c
> @@ -3,8 +3,13 @@
> #include "refs.h"
> #include "commit.h"
>
> +/*
> + * An array of replacements. The array is kept sorted by the original
> + * sha1.
> + */
> static struct replace_object {
> - unsigned char sha1[2][20];
> + unsigned char original[20];
> + unsigned char replacement[20];
> } **replace_object;
>
> static int replace_object_alloc, replace_object_nr;
> @@ -12,7 +17,7 @@ static int replace_object_alloc, replace_object_nr;
> static const unsigned char *replace_sha1_access(size_t index, void *table)
> {
> struct replace_object **replace = table;
> - return replace[index]->sha1[0];
> + return replace[index]->original;
> }
>
> static int replace_object_pos(const unsigned char *sha1)
> @@ -24,7 +29,7 @@ static int replace_object_pos(const unsigned char *sha1)
> static int register_replace_object(struct replace_object *replace,
> int ignore_dups)
> {
> - int pos = replace_object_pos(replace->sha1[0]);
> + int pos = replace_object_pos(replace->original);
>
> if (0 <= pos) {
> if (ignore_dups)
> @@ -60,14 +65,14 @@ static int register_replace_ref(const char *refname,
> const char *hash = slash ? slash + 1 : refname;
> struct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));
>
> - if (strlen(hash) != 40 || get_sha1_hex(hash, repl_obj->sha1[0])) {
> + if (strlen(hash) != 40 || get_sha1_hex(hash, repl_obj->original)) {
> free(repl_obj);
> warning("bad replace ref name: %s", refname);
> return 0;
> }
>
> /* Copy sha1 from the read ref */
> - hashcpy(repl_obj->sha1[1], sha1);
> + hashcpy(repl_obj->replacement, sha1);
>
> /* Register new object */
> if (register_replace_object(repl_obj, 1))
> @@ -107,7 +112,7 @@ const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
>
> pos = replace_object_pos(cur);
> if (0 <= pos)
> - cur = replace_object[pos]->sha1[1];
> + cur = replace_object[pos]->replacement;
> } while (0 <= pos);
>
> return cur;
next prev parent reply other threads:[~2014-02-21 18:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 16:32 [PATCH 0/6] Add a bunch of docstrings and make a few minor cleanups Michael Haggerty
2014-02-21 16:32 ` [PATCH 1/6] Add docstrings for lookup_replace_object() and do_lookup_replace_object() Michael Haggerty
2014-02-21 18:21 ` Junio C Hamano
2014-02-24 8:25 ` Michael Haggerty
2014-02-24 9:24 ` Christian Couder
2014-02-24 10:17 ` Michael Haggerty
2014-02-24 18:06 ` Junio C Hamano
2014-02-21 16:32 ` [PATCH 2/6] replace_object: use struct members instead of an array Michael Haggerty
2014-02-21 18:23 ` Junio C Hamano [this message]
2014-02-21 16:32 ` [PATCH 3/6] find_pack_entry(): document last_found_pack Michael Haggerty
2014-02-21 17:15 ` Nicolas Pitre
2014-02-21 16:32 ` [PATCH 4/6] sha1_file_name(): declare to return a const string Michael Haggerty
2014-02-21 16:32 ` [PATCH 5/6] Document a bunch of functions defined in sha1_file.c Michael Haggerty
2014-02-21 17:17 ` Nicolas Pitre
2014-02-24 18:18 ` Jakub Narębski
2014-02-24 20:01 ` Michael Haggerty
2014-02-24 20:08 ` Jonathan Nieder
2014-02-25 15:23 ` Michael Haggerty
2014-02-21 16:32 ` [PATCH 6/6] Document some functions defined in object.c Michael Haggerty
2014-02-21 17:33 ` Nicolas Pitre
2014-02-24 8:47 ` Michael Haggerty
2014-02-24 17:12 ` Junio C Hamano
2014-02-24 17:58 ` [PATCH 0/6] Add a bunch of docstrings and make a few minor cleanups Junio C Hamano
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=xmqqeh2w495f.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
--cc=nico@fluxnic.net \
--cc=peff@peff.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 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.