From: Nicolas Pitre <nico@fluxnic.net>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 1/2] Factor find_pack_entry()'s core out
Date: Wed, 01 Feb 2012 10:59:26 -0500 (EST) [thread overview]
Message-ID: <alpine.LFD.2.02.1202011056140.2759@xanadu.home> (raw)
In-Reply-To: <1328104135-475-1-git-send-email-pclouds@gmail.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2950 bytes --]
On Wed, 1 Feb 2012, Nguyễn Thái Ngọc Duy wrote:
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> sha1_file.c | 59 +++++++++++++++++++++++++++++++++--------------------------
> 1 files changed, 33 insertions(+), 26 deletions(-)
>
> diff --git a/sha1_file.c b/sha1_file.c
> index 88f2151..ff5bf42 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -2010,11 +2010,42 @@ int is_pack_valid(struct packed_git *p)
> return !open_packed_git(p);
> }
>
> +static int find_pack_entry_1(const unsigned char *sha1,
> + struct packed_git *p, struct pack_entry *e)
This looks all goot but the name. Pretty please, try to find something
that is more descriptive than "1". Suggestions:
"find_pack_entry_lookup", "find_pack_entry_inner", etc.
With that fixed, you can add:
Acked-by: Nicolas Pitre <nico@fluxnic.net>
> +{
> + off_t offset;
> + if (p->num_bad_objects) {
> + unsigned i;
> + for (i = 0; i < p->num_bad_objects; i++)
> + if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
> + return 0;
> + }
> +
> + offset = find_pack_entry_one(sha1, p);
> + if (!offset)
> + return 0;
> +
> + /*
> + * We are about to tell the caller where they can locate the
> + * requested object. We better make sure the packfile is
> + * still here and can be accessed before supplying that
> + * answer, as it may have been deleted since the index was
> + * loaded!
> + */
> + if (!is_pack_valid(p)) {
> + warning("packfile %s cannot be accessed", p->pack_name);
> + return 0;
> + }
> + e->offset = offset;
> + e->p = p;
> + hashcpy(e->sha1, sha1);
> + return 1;
> +}
> +
> static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
> {
> static struct packed_git *last_found = (void *)1;
> struct packed_git *p;
> - off_t offset;
>
> prepare_packed_git();
> if (!packed_git)
> @@ -2022,35 +2053,11 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
> p = (last_found == (void *)1) ? packed_git : last_found;
>
> do {
> - if (p->num_bad_objects) {
> - unsigned i;
> - for (i = 0; i < p->num_bad_objects; i++)
> - if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
> - goto next;
> - }
> -
> - offset = find_pack_entry_one(sha1, p);
> - if (offset) {
> - /*
> - * We are about to tell the caller where they can
> - * locate the requested object. We better make
> - * sure the packfile is still here and can be
> - * accessed before supplying that answer, as
> - * it may have been deleted since the index
> - * was loaded!
> - */
> - if (!is_pack_valid(p)) {
> - warning("packfile %s cannot be accessed", p->pack_name);
> - goto next;
> - }
> - e->offset = offset;
> - e->p = p;
> - hashcpy(e->sha1, sha1);
> + if (find_pack_entry_1(sha1, p, e)) {
> last_found = p;
> return 1;
> }
>
> - next:
> if (p == last_found)
> p = packed_git;
> else
> --
> 1.7.8.36.g69ee2
>
next prev parent reply other threads:[~2012-02-01 15:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 11:25 [PATCH] find_pack_entry(): do not keep packed_git pointer locally Nguyễn Thái Ngọc Duy
2012-01-30 23:26 ` Junio C Hamano
2012-01-31 2:01 ` Nguyen Thai Ngoc Duy
2012-01-31 4:19 ` Nicolas Pitre
[not found] ` <1328010239-29669-1-git-send-email-pclouds@gmail.com>
2012-01-31 18:02 ` [PATCH v2] " Junio C Hamano
2012-01-31 19:28 ` Nicolas Pitre
2012-02-01 13:48 ` [PATCH v3 1/2] Factor find_pack_entry()'s core out Nguyễn Thái Ngọc Duy
2012-02-01 13:48 ` [PATCH v3 2/2] find_pack_entry(): do not keep packed_git pointer locally Nguyễn Thái Ngọc Duy
2012-02-01 16:02 ` Nicolas Pitre
2012-02-02 13:53 ` [PATCH v4 " Nguyễn Thái Ngọc Duy
2012-02-01 15:59 ` Nicolas Pitre [this message]
2012-02-01 22:03 ` [PATCH v3 1/2] Factor find_pack_entry()'s core out Junio C Hamano
2012-02-01 22:33 ` Junio C Hamano
2012-02-01 23:37 ` Nicolas Pitre
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=alpine.LFD.2.02.1202011056140.2759@xanadu.home \
--to=nico@fluxnic.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/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).