Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2022-08-12 23:10:16 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-12 23:20:02 +0300
commit7ecf193f7d621f618b322498d884ee103a44522f (patch)
tree0f32a7af200f886cadbceab0fc86be37f2789f70 /diagnose.c
parent6783fd3cef0d6625e8a6d9d42d76042447078401 (diff)
builtin/diagnose.c: add '--mode' option
Create '--mode=<mode>' option in 'git diagnose' to allow users to optionally select non-default diagnostic information to include in the output archive. Additionally, document the currently-available modes, emphasizing the importance of not sharing a '--mode=all' archive publicly due to the presence of sensitive information. Note that the option parsing callback - 'option_parse_diagnose()' - is added to 'diagnose.c' rather than 'builtin/diagnose.c' so that it may be reused in future callers configuring a diagnostics archive. Helped-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diagnose.c')
-rw-r--r--diagnose.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/diagnose.c b/diagnose.c
index 9270056db2..beb0a8741b 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -13,6 +13,36 @@ struct archive_dir {
int recursive;
};
+struct diagnose_option {
+ enum diagnose_mode mode;
+ const char *option_name;
+};
+
+static struct diagnose_option diagnose_options[] = {
+ { DIAGNOSE_STATS, "stats" },
+ { DIAGNOSE_ALL, "all" },
+};
+
+int option_parse_diagnose(const struct option *opt, const char *arg, int unset)
+{
+ int i;
+ enum diagnose_mode *diagnose = opt->value;
+
+ if (!arg) {
+ *diagnose = unset ? DIAGNOSE_NONE : DIAGNOSE_STATS;
+ return 0;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(diagnose_options); i++) {
+ if (!strcmp(arg, diagnose_options[i].option_name)) {
+ *diagnose = diagnose_options[i].mode;
+ return 0;
+ }
+ }
+
+ return error(_("invalid --%s value '%s'"), opt->long_name, arg);
+}
+
static void dir_file_stats_objects(const char *full_path, size_t full_path_len,
const char *file_name, void *data)
{