|
12 | 12 | #include "packfile.h"
|
13 | 13 | #include "help.h"
|
14 | 14 | #include "archive.h"
|
| 15 | +#include "object-store.h" |
15 | 16 |
|
16 | 17 | /*
|
17 | 18 | * Remove the deepest subdirectory in the provided path string. Path must not
|
@@ -594,6 +595,29 @@ static int cmd_clone(int argc, const char **argv)
|
594 | 595 | return res;
|
595 | 596 | }
|
596 | 597 |
|
| 598 | +static void dir_file_stats_objects(const char *full_path, size_t full_path_len, |
| 599 | + const char *file_name, void *data) |
| 600 | +{ |
| 601 | + struct strbuf *buf = data; |
| 602 | + struct stat st; |
| 603 | + |
| 604 | + if (!stat(full_path, &st)) |
| 605 | + strbuf_addf(buf, "%-70s %16" PRIuMAX "\n", file_name, |
| 606 | + (uintmax_t)st.st_size); |
| 607 | +} |
| 608 | + |
| 609 | +static int dir_file_stats(struct object_directory *object_dir, void *data) |
| 610 | +{ |
| 611 | + struct strbuf *buf = data; |
| 612 | + |
| 613 | + strbuf_addf(buf, "Contents of %s:\n", object_dir->path); |
| 614 | + |
| 615 | + for_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects, |
| 616 | + data); |
| 617 | + |
| 618 | + return 0; |
| 619 | +} |
| 620 | + |
597 | 621 | static int cmd_diagnose(int argc, const char **argv)
|
598 | 622 | {
|
599 | 623 | struct option options[] = {
|
@@ -656,6 +680,12 @@ static int cmd_diagnose(int argc, const char **argv)
|
656 | 680 | "--add-virtual-file=diagnostics.log:%.*s",
|
657 | 681 | (int)buf.len, buf.buf);
|
658 | 682 |
|
| 683 | + strbuf_reset(&buf); |
| 684 | + strbuf_addstr(&buf, "--add-virtual-file=packs-local.txt:"); |
| 685 | + dir_file_stats(the_repository->objects->odb, &buf); |
| 686 | + foreach_alt_odb(dir_file_stats, &buf); |
| 687 | + strvec_push(&archiver_args, buf.buf); |
| 688 | + |
659 | 689 | if ((res = add_directory_to_archiver(&archiver_args, ".git", 0)) ||
|
660 | 690 | (res = add_directory_to_archiver(&archiver_args, ".git/hooks", 0)) ||
|
661 | 691 | (res = add_directory_to_archiver(&archiver_args, ".git/info", 0)) ||
|
|
0 commit comments