From: Junio C Hamano <gitster@pobox.com>
To: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Cc: Frank Lichtenheld <frank@lichtenheld.de>, git@vger.kernel.org
Subject: Re: [PATCH] Fix "unpack-objects --strict"
Date: Fri, 14 Aug 2009 00:41:31 -0700 [thread overview]
Message-ID: <7vhbwasuz8.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20090814060307.GA31721@auto.tuwien.ac.at> (Martin Koegler's message of "Fri\, 14 Aug 2009 08\:03\:07 +0200")
Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> What about this check:
>> @@ -184,7 +184,7 @@ static int check_object(struct object *obj, int type, void *data)
>> if (!obj)
>> return 0;
>
> This is neccessary to skip already written objects (eg. blobs,
> obj_list[i].obj == NULL).
You can fix that issue by teaching write_rest() to check what it feeds
check_object(), can't you?
> I'm not sure, if fsck_walk can call check_object with obj == NULL
> under some (rare) conditions. If yes, the return code should be
> changed to 1.
I think that is a sensible change to signal an error regardless. For
example, fsck_walk_tree() will make a callback to you (meaning, walk()
function pointer points at your check_object() function) like this:
while (tree_entry(&desc, &entry)) {
int result;
if (S_ISGITLINK(entry.mode))
continue;
if (S_ISDIR(entry.mode))
result = walk(&lookup_tree(entry.sha1)->object, OBJ_TREE, data);
so while you are checking a tree object you received, upon hitting a
subtree of that tree, it will lookup_tree() it, and if that tree is
missing, you will be called with NULL.
On top of the previous patch, a fix would look like this, I think, but
please double check.
Thanks.
builtin-unpack-objects.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 2522c2d..bae00ea 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -181,7 +181,7 @@ static void write_cached_object(struct object *obj)
static int check_object(struct object *obj, int type, void *data)
{
if (!obj)
- return 0;
+ return 1;
if (obj->flags & FLAG_WRITTEN)
return 0;
@@ -209,8 +209,10 @@ static int check_object(struct object *obj, int type, void *data)
static void write_rest(void)
{
unsigned i;
- for (i = 0; i < nr_objects; i++)
- check_object(obj_list[i].obj, OBJ_ANY, 0);
+ for (i = 0; i < nr_objects; i++) {
+ if (obj_list[i].obj)
+ check_object(obj_list[i].obj, OBJ_ANY, 0);
+ }
}
static void added_object(unsigned nr, enum object_type type,
next prev parent reply other threads:[~2009-08-14 7:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-13 10:32 [BUG] Submodules problem with subdirectories and pushing Frank Lichtenheld
2009-08-13 11:19 ` Frank Lichtenheld
2009-08-13 19:33 ` [PATCH] Fix "unpack-objects --strict" Junio C Hamano
2009-08-14 6:03 ` Martin Koegler
2009-08-14 6:32 ` Junio C Hamano
2009-08-14 7:19 ` Martin Koegler
2009-08-14 7:31 ` Junio C Hamano
2009-08-14 7:41 ` Junio C Hamano [this message]
2009-08-14 9:30 ` Frank Lichtenheld
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=7vhbwasuz8.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=frank@lichtenheld.de \
--cc=git@vger.kernel.org \
--cc=mkoegler@auto.tuwien.ac.at \
/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