From: Victoria Dye <vdye@xxxxxxxxxx> Add a '--no-report' option to 'git bugreport' to avoid writing the 'git-bugreport-<suffix>.txt' file. This gives users the option of creating only the diagnostic archive with '--diagnose' and mirroring the behavior of the original 'scalar diagnose' as closely as possible. If a user specifies '--no-report' *without* also specifying '--diagnose', the 'git bugreport' operation is a no-op; a warning message is printed and the command returns with a non-error exit code. Signed-off-by: Victoria Dye <vdye@xxxxxxxxxx> --- Documentation/git-bugreport.txt | 6 ++++++ builtin/bugreport.c | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Documentation/git-bugreport.txt b/Documentation/git-bugreport.txt index b55658bc287..5eae7a4f950 100644 --- a/Documentation/git-bugreport.txt +++ b/Documentation/git-bugreport.txt @@ -58,6 +58,12 @@ OPTIONS archive is written to the same output directory as the bug report and is named 'git-diagnostics-<formatted suffix>'. +--no-report:: + Do not write out a 'git-bugreport-<suffix>.txt' file. This option is + intended for use with `--diagnose` when only the diagnostic archive is + needed. If `--no-report` is used without `--diagnose`, `git bugreport` + is a no-op. + GIT --- Part of the linkgit:git[1] suite diff --git a/builtin/bugreport.c b/builtin/bugreport.c index dea11f91386..5ecff70276a 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -361,7 +361,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) int report = -1; time_t now = time(NULL); struct tm tm; - int diagnose = 0; + int diagnose = 0, skip_summary = 0; char *option_output = NULL; char *option_suffix = "%Y-%m-%d-%H%M"; const char *user_relative_path = NULL; @@ -371,6 +371,8 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) const struct option bugreport_options[] = { OPT_BOOL(0, "diagnose", &diagnose, N_("generate a diagnostics zip archive")), + OPT_BOOL(0, "no-report", &skip_summary, + N_("do not create a summary report")), OPT_STRING('o', "output-directory", &option_output, N_("path"), N_("specify a destination for the bugreport file(s)")), OPT_STRING('s', "suffix", &option_suffix, N_("format"), @@ -381,6 +383,11 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, bugreport_options, bugreport_usage, 0); + if (skip_summary && !diagnose) { + warning(_("Nothing to do!")); + return 0; + } + /* Prepare the path to put the result */ prefixed_filename = prefix_filename(prefix, option_output ? option_output : ""); @@ -415,6 +422,13 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) strbuf_release(&zip_path); } + if (skip_summary) { + free(prefixed_filename); + strbuf_release(&buffer); + strbuf_release(&report_path); + return 0; + } + /* Prepare the report contents */ get_bug_template(&buffer); -- gitgitgadget