scalar-diagnose: move functionality to common location

Move the core functionality of 'scalar diagnose' into a new 'diagnose.[c,h]'
library to prepare for new callers in the main Git tree generating
diagnostic archives. These callers will be introduced in subsequent patches.

While this patch appears large, it is mostly made up of moving code out of
'scalar.c' and into 'diagnose.c'. Specifically, the functions

- dir_file_stats_objects()
- dir_file_stats()
- count_files()
- loose_objs_stats()
- add_directory_to_archiver()

are all copied verbatim from 'scalar.c'. The 'create_diagnostics_archive()'
function is a mostly identical (partial) copy of 'cmd_diagnose()', with the
primary changes being that 'zip_path' is an input and "Enlistment root" is
corrected to "Repository root" in the archiver log.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Victoria Dye
2022-08-12 20:10:13 +00:00
committed by Junio C Hamano
parent 435a2535b7
commit bb2c34956a
4 changed files with 227 additions and 200 deletions

8
diagnose.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef DIAGNOSE_H
#define DIAGNOSE_H
#include "strbuf.h"
int create_diagnostics_archive(struct strbuf *zip_path);
#endif /* DIAGNOSE_H */