From: "Shawn O. Pearce" <spearce@spearce.org>
To: Mike Hommey <mh@glandium.org>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [RFC] Don't expect verify_pack() callers to set pack_size
Date: Sun, 27 Jan 2008 12:18:26 -0500 [thread overview]
Message-ID: <20080127171826.GV24004@spearce.org> (raw)
In-Reply-To: <1201446098-18868-1-git-send-email-mh@glandium.org>
Mike Hommey <mh@glandium.org> wrote:
> Since use_pack() will end up populating pack_size if it is not already set,
> we can just adapt the code in verify_packfile() such that it doesn't require
> pack_size to be set beforehand.
>
> This allows callers not to have to set pack_size themselves, and we can thus
> revert changes from 1c23d794.
That's a good improvement in code clarity. When I implemented
1c23 I wasn't sure what was initialized in the struct packed_git
that the HTTP code was slugging around in request->userData, and
it was hard to track down. 1c23 was a quick fix to get HTTP fetch
working again when sp/mmap merged into next.
I'm guessing you have figured out it is not actually open at this
point, which makes sense as we did fclose() calls to close out
the writer. So sha1_file.c needs to open a new file descriptor.
use_pack() will force it to be opened and the open packfile function
does update the pack_size if we don't have it yet.
Acked-by: Shawn O. Pearce <spearce@spearce.org>
> diff --git a/pack-check.c b/pack-check.c
> index d7dd62b..e7f0126 100644
> --- a/pack-check.c
> +++ b/pack-check.c
> @@ -37,14 +37,16 @@ static int verify_packfile(struct packed_git *p,
> */
>
> SHA1_Init(&ctx);
> - while (offset < pack_sig) {
> + do {
> unsigned int remaining;
> unsigned char *in = use_pack(p, w_curs, offset, &remaining);
> offset += remaining;
> + if (pack_sig == 0)
> + pack_sig = p->pack_size - 20;
fyi, we prefer "if (!pack_sig)" in Git for equality with 0 tests.
--
Shawn.
prev parent reply other threads:[~2008-01-27 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-27 15:01 [RFC] Don't expect verify_pack() callers to set pack_size Mike Hommey
2008-01-27 17:18 ` Shawn O. Pearce [this message]
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=20080127171826.GV24004@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mh@glandium.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.
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).