@matheusbsbs / matheus-bagliano / commits / e2ac7cb5fb
Fork 0

Don't assume tree entries that are not dirs are blobs

When scanning the trees in track_tree_refs() there is a "lazy" test that assumes that entries are either directories or files. Don't do that. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sam Vilain committed Jun 6, 2007 at 22:25 UTC e2ac7cb5fbcf1407003aa07cdcd14141527ea2e3
2 files changed +9 -1
object.c
+3
@@ -160,8 +160,11 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
160 parse_tag_buffer(tag, buffer, size);
161 obj = &tag->object;
162 } else {
163 + warning("object %s has unknown type id %d\n", sha1_to_hex(sha1), type);
164 obj = NULL;
165 }
166 + if (obj && obj->type == OBJ_NONE)
167 + obj->type = type;
168 *eaten_p = eaten;
169 return obj;
170 }
tree.c
+6 -1
@@ -173,8 +173,13 @@ static void track_tree_refs(struct tree *item)
173 continue;
174 if (S_ISDIR(entry.mode))
175 obj = &lookup_tree(entry.sha1)->object;
176 - else
176 + else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
177 obj = &lookup_blob(entry.sha1)->object;
178 + else {
179 + warning("in tree %s: entry %s has bad mode %.6o\n",
180 + sha1_to_hex(item->object.sha1), entry.path, entry.mode);
181 + obj = lookup_unknown_object(entry.sha1);
182 + }
183 refs->ref[i++] = obj;
184 }
185 set_object_refs(&item->object, refs);