aboutsummaryrefslogtreecommitdiffstats
path: root/diagnose.c
diff options
context:
space:
mode:
Diffstat (limited to 'diagnose.c')
-rw-r--r--diagnose.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/diagnose.c b/diagnose.c
index cc2d535b60..5092bf80d3 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "diagnose.h"
#include "compat/disk.h"
@@ -9,9 +7,10 @@
#include "gettext.h"
#include "hex.h"
#include "strvec.h"
-#include "object-store-ll.h"
+#include "odb.h"
#include "packfile.h"
#include "parse-options.h"
+#include "repository.h"
#include "write-or-die.h"
struct archive_dir {
@@ -31,7 +30,6 @@ static struct diagnose_option diagnose_options[] = {
int option_parse_diagnose(const struct option *opt, const char *arg, int unset)
{
- int i;
enum diagnose_mode *diagnose = opt->value;
if (!arg) {
@@ -39,7 +37,7 @@ int option_parse_diagnose(const struct option *opt, const char *arg, int unset)
return 0;
}
- for (i = 0; i < ARRAY_SIZE(diagnose_options); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(diagnose_options); i++) {
if (!strcmp(arg, diagnose_options[i].option_name)) {
*diagnose = diagnose_options[i].mode;
return 0;
@@ -61,13 +59,13 @@ static void dir_file_stats_objects(const char *full_path,
(uintmax_t)st.st_size);
}
-static int dir_file_stats(struct object_directory *object_dir, void *data)
+static int dir_file_stats(struct odb_source *source, void *data)
{
struct strbuf *buf = data;
- strbuf_addf(buf, "Contents of %s:\n", object_dir->path);
+ strbuf_addf(buf, "Contents of %s:\n", source->path);
- for_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects,
+ for_each_file_in_pack_dir(source->path, dir_file_stats_objects,
data);
return 0;
@@ -180,13 +178,15 @@ static int add_directory_to_archiver(struct strvec *archiver_args,
return res;
}
-int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
+int create_diagnostics_archive(struct repository *r,
+ struct strbuf *zip_path,
+ enum diagnose_mode mode)
{
struct strvec archiver_args = STRVEC_INIT;
char **argv_copy = NULL;
int stdout_fd = -1, archiver_fd = -1;
struct strbuf buf = STRBUF_INIT;
- int res, i;
+ int res;
struct archive_dir archive_dirs[] = {
{ ".git", 0 },
{ ".git/hooks", 0 },
@@ -219,7 +219,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
strbuf_addstr(&buf, "Collecting diagnostic info\n\n");
get_version_info(&buf, 1);
- strbuf_addf(&buf, "Repository root: %s\n", the_repository->worktree);
+ strbuf_addf(&buf, "Repository root: %s\n", r->worktree);
get_disk_info(&buf);
write_or_die(stdout_fd, buf.buf, buf.len);
strvec_pushf(&archiver_args,
@@ -228,8 +228,8 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
strbuf_reset(&buf);
strbuf_addstr(&buf, "--add-virtual-file=packs-local.txt:");
- dir_file_stats(the_repository->objects->odb, &buf);
- foreach_alt_odb(dir_file_stats, &buf);
+ dir_file_stats(r->objects->sources, &buf);
+ odb_for_each_alternate(r->objects, dir_file_stats, &buf);
strvec_push(&archiver_args, buf.buf);
strbuf_reset(&buf);
@@ -239,7 +239,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
/* Only include this if explicitly requested */
if (mode == DIAGNOSE_ALL) {
- for (i = 0; i < ARRAY_SIZE(archive_dirs); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(archive_dirs); i++) {
if (add_directory_to_archiver(&archiver_args,
archive_dirs[i].path,
archive_dirs[i].recursive)) {
@@ -251,13 +251,13 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)
}
strvec_pushl(&archiver_args, "--prefix=",
- oid_to_hex(the_hash_algo->empty_tree), "--", NULL);
+ oid_to_hex(r->hash_algo->empty_tree), "--", NULL);
/* `write_archive()` modifies the `argv` passed to it. Let it. */
argv_copy = xmemdupz(archiver_args.v,
sizeof(char *) * archiver_args.nr);
res = write_archive(archiver_args.nr, (const char **)argv_copy, NULL,
- the_repository, NULL, 0);
+ r, NULL, 0);
if (res) {
error(_("failed to write archive"));
goto diagnose_cleanup;