Skip to content

Commit 672196a

Browse files
vdyegitster
authored andcommitted
scalar-diagnose: use 'git diagnose --mode=all'
Replace implementation of 'scalar diagnose' with an internal invocation of 'git diagnose --mode=all'. This simplifies the implementation of 'cmd_diagnose' by making it a direct alias of 'git diagnose' and removes some code in 'scalar.c' that is duplicated in 'builtin/diagnose.c'. The simplicity of the alias also sets up a clean deprecation path for 'scalar diagnose' (in favor of 'git diagnose'), if that is desired in the future. This introduces one minor change to the output of 'scalar diagnose', which is that the prefix of the created zip archive is changed from 'scalar_' to 'git-diagnostics-'. Helped-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aac0e8f commit 672196a

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

contrib/scalar/scalar.c

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "dir.h"
1212
#include "packfile.h"
1313
#include "help.h"
14-
#include "diagnose.h"
1514

1615
/*
1716
* Remove the deepest subdirectory in the provided path string. Path must not
@@ -510,34 +509,19 @@ static int cmd_diagnose(int argc, const char **argv)
510509
N_("scalar diagnose [<enlistment>]"),
511510
NULL
512511
};
513-
struct strbuf zip_path = STRBUF_INIT;
514-
time_t now = time(NULL);
515-
struct tm tm;
512+
struct strbuf diagnostics_root = STRBUF_INIT;
516513
int res = 0;
517514

518515
argc = parse_options(argc, argv, NULL, options,
519516
usage, 0);
520517

521-
setup_enlistment_directory(argc, argv, usage, options, &zip_path);
522-
523-
strbuf_addstr(&zip_path, "/.scalarDiagnostics/scalar_");
524-
strbuf_addftime(&zip_path,
525-
"%Y%m%d_%H%M%S", localtime_r(&now, &tm), 0, 0);
526-
strbuf_addstr(&zip_path, ".zip");
527-
switch (safe_create_leading_directories(zip_path.buf)) {
528-
case SCLD_EXISTS:
529-
case SCLD_OK:
530-
break;
531-
default:
532-
error_errno(_("could not create directory for '%s'"),
533-
zip_path.buf);
534-
goto diagnose_cleanup;
535-
}
518+
setup_enlistment_directory(argc, argv, usage, options, &diagnostics_root);
519+
strbuf_addstr(&diagnostics_root, "/.scalarDiagnostics");
536520

537-
res = create_diagnostics_archive(&zip_path, DIAGNOSE_ALL);
521+
res = run_git("diagnose", "--mode=all", "-s", "%Y%m%d_%H%M%S",
522+
"-o", diagnostics_root.buf, NULL);
538523

539-
diagnose_cleanup:
540-
strbuf_release(&zip_path);
524+
strbuf_release(&diagnostics_root);
541525
return res;
542526
}
543527

0 commit comments

Comments
 (0)