| 352 | } |
| 353 | |
| 354 | static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *options) |
| 355 | { |
| 356 | struct tree_desc desc; |
| 357 | struct name_entry entry; |
| 358 | int res = 0; |
| 359 | const char *name; |
| 360 | |
| 361 | if (repo_parse_tree(options->repo, tree)) |
| 362 | return -1; |
| 363 | |
| 364 | name = fsck_get_object_name(options, &tree->object.oid); |
| 365 | if (init_tree_desc_gently(&desc, &tree->object.oid, |
| 366 | tree->buffer, tree->size, 0)) |
| 367 | return -1; |
| 368 | while (tree_entry_gently(&desc, &entry)) { |
| 369 | struct object *obj; |
| 370 | int result; |
| 371 | |
| 372 | if (S_ISGITLINK(entry.mode)) |
| 373 | continue; |
| 374 | |
| 375 | if (S_ISDIR(entry.mode)) { |
| 376 | obj = (struct object *)lookup_tree(options->repo, &entry.oid); |
| 377 | if (name && obj) |
| 378 | fsck_put_object_name(options, &entry.oid, "%s%s/", |
| 379 | name, entry.path); |
| 380 | result = options->walk(obj, OBJ_TREE, data, options); |
| 381 | } |
| 382 | else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) { |
| 383 | obj = (struct object *)lookup_blob(options->repo, &entry.oid); |
| 384 | if (name && obj) |
| 385 | fsck_put_object_name(options, &entry.oid, "%s%s", |
| 386 | name, entry.path); |
| 387 | result = options->walk(obj, OBJ_BLOB, data, options); |
| 388 | } |
| 389 | else { |
| 390 | result = error("in tree %s: entry %s has bad mode %.6o", |
| 391 | fsck_describe_object(options, &tree->object.oid), |
| 392 | entry.path, entry.mode); |
| 393 | } |
| 394 | if (result < 0) |
| 395 | return result; |
| 396 | if (!res) |
| 397 | res = result; |
| 398 | } |
| 399 | return res; |
| 400 | } |
| 401 | |
| 402 | static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_options *options) |
| 403 | { |
no test coverage detected