mirror of
https://github.com/git-for-windows/git.git
synced 2026-02-04 03:22:18 -06:00
Start work on a new 'git survey' command to scan the repository for monorepo performance and scaling problems. The goal is to measure the various known "dimensions of scale" and serve as a foundation for adding additional measurements as we learn more about Git monorepo scaling problems. The initial goal is to complement the scanning and analysis performed by the GO-based 'git-sizer' (https://github.com/github/git-sizer) tool. It is hoped that by creating a builtin command, we may be able to take advantage of internal Git data structures and code that is not accessible from GO to gain further insight into potential scaling problems. Co-authored-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Jeff Hostetler <git@jeffhostetler.com> Signed-off-by: Derrick Stolee <stolee@gmail.com>
76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
#define USE_THE_REPOSITORY_VARIABLE
|
|
|
|
#include "builtin.h"
|
|
#include "config.h"
|
|
#include "parse-options.h"
|
|
|
|
static const char * const survey_usage[] = {
|
|
N_("(EXPERIMENTAL!) git survey <options>"),
|
|
NULL,
|
|
};
|
|
|
|
struct survey_opts {
|
|
int verbose;
|
|
int show_progress;
|
|
};
|
|
|
|
struct survey_context {
|
|
struct repository *repo;
|
|
|
|
/* Options that control what is done. */
|
|
struct survey_opts opts;
|
|
};
|
|
|
|
static int survey_load_config_cb(const char *var, const char *value,
|
|
const struct config_context *cctx, void *pvoid)
|
|
{
|
|
struct survey_context *ctx = pvoid;
|
|
|
|
if (!strcmp(var, "survey.verbose")) {
|
|
ctx->opts.verbose = git_config_bool(var, value);
|
|
return 0;
|
|
}
|
|
if (!strcmp(var, "survey.progress")) {
|
|
ctx->opts.show_progress = git_config_bool(var, value);
|
|
return 0;
|
|
}
|
|
|
|
return git_default_config(var, value, cctx, pvoid);
|
|
}
|
|
|
|
static void survey_load_config(struct survey_context *ctx)
|
|
{
|
|
repo_config(the_repository, survey_load_config_cb, ctx);
|
|
}
|
|
|
|
int cmd_survey(int argc, const char **argv, const char *prefix, struct repository *repo)
|
|
{
|
|
static struct survey_context ctx = {
|
|
.opts = {
|
|
.verbose = 0,
|
|
.show_progress = -1, /* defaults to isatty(2) */
|
|
},
|
|
};
|
|
|
|
static struct option survey_options[] = {
|
|
OPT__VERBOSE(&ctx.opts.verbose, N_("verbose output")),
|
|
OPT_BOOL(0, "progress", &ctx.opts.show_progress, N_("show progress")),
|
|
OPT_END(),
|
|
};
|
|
|
|
show_usage_with_options_if_asked(argc, argv,
|
|
survey_usage, survey_options);
|
|
|
|
ctx.repo = repo;
|
|
|
|
prepare_repo_settings(ctx.repo);
|
|
survey_load_config(&ctx);
|
|
|
|
argc = parse_options(argc, argv, prefix, survey_options, survey_usage, 0);
|
|
|
|
if (ctx.opts.show_progress < 0)
|
|
ctx.opts.show_progress = isatty(2);
|
|
|
|
return 0;
|
|
}
|