git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 06/18] Don't expect verify_pack() callers to set pack_size
@ 2009-05-24 14:19 Tay Ray Chuan
  2009-05-24 20:43 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Tay Ray Chuan @ 2009-05-24 14:19 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Johannes Schindelin, Mike Hommey

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 (Don't die in git-http-fetch when fetching packs).

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 pack-check.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pack-check.c b/pack-check.c
index 90c33b1..166ca70 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -49,7 +49,7 @@ static int verify_packfile(struct packed_git *p,
 	const unsigned char *index_base = p->index_data;
 	git_SHA_CTX ctx;
 	unsigned char sha1[20], *pack_sig;
-	off_t offset = 0, pack_sig_ofs = p->pack_size - 20;
+	off_t offset = 0, pack_sig_ofs = 0;
 	uint32_t nr_objects, i;
 	int err = 0;
 	struct idx_entry *entries;
@@ -61,14 +61,16 @@ static int verify_packfile(struct packed_git *p,
 	 */

 	git_SHA1_Init(&ctx);
-	while (offset < pack_sig_ofs) {
+	do {
 		unsigned int remaining;
 		unsigned char *in = use_pack(p, w_curs, offset, &remaining);
 		offset += remaining;
+		if (!pack_sig_ofs)
+			pack_sig_ofs = p->pack_size - 20;
 		if (offset > pack_sig_ofs)
 			remaining -= (unsigned int)(offset - pack_sig_ofs);
 		git_SHA1_Update(&ctx, in, remaining);
-	}
+	} while (offset < pack_sig_ofs);
 	git_SHA1_Final(sha1, &ctx);
 	pack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);
 	if (hashcmp(sha1, pack_sig))
--
1.6.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 06/18] Don't expect verify_pack() callers to set pack_size
  2009-05-24 14:19 [PATCH 06/18] Don't expect verify_pack() callers to set pack_size Tay Ray Chuan
@ 2009-05-24 20:43 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2009-05-24 20:43 UTC (permalink / raw)
  To: Tay Ray Chuan
  Cc: Git Mailing List, Junio C Hamano, Johannes Schindelin,
	Mike Hommey

Tay Ray Chuan <rctay89@gmail.com> writes:

> 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 (Don't die in git-http-fetch when fetching packs).
>
> Signed-off-by: Mike Hommey <mh@glandium.org>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>

When you forward somebody else's patch, please be careful not to lose the
attribution, by having

	From: Mike Hommey <mh@glandium.org>
        Date: <<<the original author date from Mike>>>

and an empty line before you start the commit log message.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-24 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-24 14:19 [PATCH 06/18] Don't expect verify_pack() callers to set pack_size Tay Ray Chuan
2009-05-24 20:43 ` Junio C Hamano

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).