git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] Ensure the pack index is opened before access
Date: Wed, 30 May 2007 02:13:14 -0400	[thread overview]
Message-ID: <20070530061314.GB12738@spearce.org> (raw)

In this particular location of fsck the index should have already
been opened by verify_pack, which is called just before we get
here and loop through the object names.  However, just in case a
future version of that function does not use the index file we'll
double-check its open before we access the num_objects field.

Better safe now than sorry later.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-fsck.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index cbbcaf0..9959818 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -668,7 +668,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
 			verify_pack(p, 0);
 
 		for (p = packed_git; p; p = p->next) {
-			uint32_t i, num = p->num_objects;
+			uint32_t i, num;
+			if (open_pack_index(p))
+				continue;
+			num = p->num_objects;
 			for (i = 0; i < num; i++)
 				fsck_sha1(nth_packed_object_sha1(p, i));
 		}
-- 
1.5.2.869.g6b3ba

                 reply	other threads:[~2007-05-30  6:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070530061314.GB12738@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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 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).