From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 2/2] fsck: check loose objects from alternate object stores by default
Date: Fri, 30 Jan 2009 01:13:04 -0800 [thread overview]
Message-ID: <7vd4e5b1i7.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.2.00.0901291512260.3054@localhost.localdomain> (Linus Torvalds's message of "Thu, 29 Jan 2009 15:21:55 -0800 (PST)")
"git fsck" used to validate only loose objects that are local and nothing
else by default. This is not just too little when a repository is
borrowing objects from other object stores, but also caused the
connectivity check to mistakenly declare loose objects borrowed from them
to be missing.
The rationale behind the default mode that validates only loose objects is
because these objects are still young and more unlikely to have been
pushed to other repositories yet. That holds for loose objects borrowed
from alternate object stores as well.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* This implements your earlier suggestion. We might want to say where
the corrupt object was found when fsck_sha1() reports problems, but
that is an issue that already exists when the command is run with
--full.
builtin-fsck.c | 21 ++++++++++++---------
t/t1450-fsck.sh | 16 ++++++++++++++--
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 2cfff43..64dffa5 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -586,6 +586,7 @@ static struct option fsck_opts[] = {
int cmd_fsck(int argc, const char **argv, const char *prefix)
{
int i, heads;
+ struct alternate_object_database *alt;
errors_found = 0;
@@ -597,17 +598,19 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
fsck_head_link();
fsck_object_dir(get_object_directory());
+
+ prepare_alt_odb();
+ for (alt = alt_odb_list; alt; alt = alt->next) {
+ char namebuf[PATH_MAX];
+ int namelen = alt->name - alt->base;
+ memcpy(namebuf, alt->base, namelen);
+ namebuf[namelen - 1] = 0;
+ fsck_object_dir(namebuf);
+ }
+
if (check_full) {
- struct alternate_object_database *alt;
struct packed_git *p;
- prepare_alt_odb();
- for (alt = alt_odb_list; alt; alt = alt->next) {
- char namebuf[PATH_MAX];
- int namelen = alt->name - alt->base;
- memcpy(namebuf, alt->base, namelen);
- namebuf[namelen - 1] = 0;
- fsck_object_dir(namebuf);
- }
+
prepare_packed_git();
for (p = packed_git; p; p = p->next)
/* verify gives error messages itself */
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 5166566..6e64e44 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -5,9 +5,9 @@ test_description='git fsck random collection of tests'
. ./test-lib.sh
test_expect_success setup '
- test_commit A &&
+ test_commit A fileA one &&
git checkout HEAD^0 &&
- test_commit B &&
+ test_commit B fileB two &&
git reflog expire --expire=now --all
'
@@ -15,4 +15,16 @@ test_expect_success 'HEAD is part of refs' '
test 0 = $(git fsck | wc -l)
'
+test_expect_success 'loose objects borrowed from alternate are not missing' '
+ mkdir another &&
+ (
+ cd another &&
+ git init &&
+ echo ../../../.git/objects >.git/objects/info/alternates &&
+ test_commit C fileC one &&
+ git fsck >out &&
+ ! grep "missing blob" out
+ )
+'
+
test_done
--
1.6.1.2.312.g5be3c
next prev parent reply other threads:[~2009-01-30 9:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 6:24 Something weird is happening H. Peter Anvin
2009-01-29 6:56 ` Junio C Hamano
[not found] ` <20090129113846.GA10645@elte.hu>
2009-01-29 12:05 ` Ingo Molnar
2009-01-29 22:20 ` René Scharfe
2009-01-29 23:01 ` Daniel Barkalow
2009-01-31 14:39 ` [PATCH] merge: fix out-of-bounds memory access René Scharfe
2009-01-29 13:45 ` Something weird is happening Sverre Rabbelier
2009-02-01 1:31 ` Junio C Hamano
2009-01-29 10:50 ` Ingo Molnar
2009-01-29 10:52 ` Ingo Molnar
2009-01-29 21:45 ` Junio C Hamano
2009-01-29 22:10 ` H. Peter Anvin
2009-01-29 22:35 ` Ingo Molnar
[not found] ` <20090129224357.GA18471@elte.hu>
2009-01-29 22:47 ` H. Peter Anvin
2009-01-29 22:57 ` Junio C Hamano
2009-01-29 23:21 ` Linus Torvalds
2009-01-30 9:12 ` [PATCH 1/2] fsck: HEAD is part of refs Junio C Hamano
2009-01-30 9:27 ` Johannes Sixt
2009-02-01 0:53 ` Junio C Hamano
2009-01-30 16:47 ` Johannes Schindelin
2009-01-31 21:45 ` Nanako Shiraishi
2009-02-01 0:57 ` Junio C Hamano
2009-01-30 9:13 ` Junio C Hamano [this message]
2009-01-29 22:34 ` Something weird is happening Ingo Molnar
2009-01-29 22:36 ` H. Peter Anvin
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=7vd4e5b1i7.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=hpa@zytor.com \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.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).