@@ -67,6 +67,39 @@ static int dir_file_stats(struct object_directory *object_dir, void *data)
6767 return 0 ;
6868}
6969
70+ static void dir_stats (struct strbuf * buf , const char * path )
71+ {
72+ DIR * dir = opendir (path );
73+ struct dirent * e ;
74+ struct stat e_stat ;
75+ struct strbuf file_path = STRBUF_INIT ;
76+ size_t base_path_len ;
77+
78+ if (!dir )
79+ return ;
80+
81+ strbuf_addstr (buf , "Contents of " );
82+ strbuf_add_absolute_path (buf , path );
83+ strbuf_addstr (buf , ":\n" );
84+
85+ strbuf_add_absolute_path (& file_path , path );
86+ strbuf_addch (& file_path , '/' );
87+ base_path_len = file_path .len ;
88+
89+ while ((e = readdir (dir )) != NULL )
90+ if (!is_dot_or_dotdot (e -> d_name ) && e -> d_type == DT_REG ) {
91+ strbuf_setlen (& file_path , base_path_len );
92+ strbuf_addstr (& file_path , e -> d_name );
93+ if (!stat (file_path .buf , & e_stat ))
94+ strbuf_addf (buf , "%-70s %16" PRIuMAX "\n" ,
95+ e -> d_name ,
96+ (uintmax_t )e_stat .st_size );
97+ }
98+
99+ strbuf_release (& file_path );
100+ closedir (dir );
101+ }
102+
70103static int count_files (char * path )
71104{
72105 DIR * dir = opendir (path );
@@ -174,7 +207,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
174207 char * * argv_copy = NULL ;
175208 int stdout_fd = -1 , archiver_fd = -1 ;
176209 char * cache_server_url = NULL , * shared_cache = NULL ;
177- struct strbuf buf = STRBUF_INIT ;
210+ struct strbuf buf = STRBUF_INIT , path = STRBUF_INIT ;
178211 int res , i ;
179212 struct archive_dir archive_dirs [] = {
180213 { ".git" , 0 },
@@ -246,6 +279,39 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
246279 }
247280 }
248281
282+ if (shared_cache ) {
283+ strbuf_reset (& buf );
284+ strbuf_addf (& path , "%s/pack" , shared_cache );
285+ strbuf_reset (& buf );
286+ strbuf_addstr (& buf , "--add-virtual-file=packs-cached.txt:" );
287+ dir_stats (& buf , path .buf );
288+ strvec_push (& archiver_args , buf .buf );
289+
290+ strbuf_reset (& buf );
291+ strbuf_addstr (& buf , "--add-virtual-file=objects-cached.txt:" );
292+ loose_objs_stats (& buf , shared_cache );
293+ strvec_push (& archiver_args , buf .buf );
294+
295+ strbuf_reset (& path );
296+ strbuf_addf (& path , "%s/info" , shared_cache );
297+ if (is_directory (path .buf )) {
298+ DIR * dir = opendir (path .buf );
299+ struct dirent * e ;
300+
301+ while ((e = readdir (dir ))) {
302+ if (!strcmp ("." , e -> d_name ) || !strcmp (".." , e -> d_name ))
303+ continue ;
304+
305+ strbuf_reset (& buf );
306+ strbuf_addf (& buf , "--add-virtual-file=info/%s:" , e -> d_name );
307+ if (strbuf_read_file (& buf , path .buf , 0 ) < 0 )
308+ goto diagnose_cleanup ;
309+ strvec_push (& archiver_args , buf .buf );
310+ }
311+ closedir (dir );
312+ }
313+ }
314+
249315 strvec_pushl (& archiver_args , "--prefix=" ,
250316 oid_to_hex (the_hash_algo -> empty_tree ), "--" , NULL );
251317
0 commit comments