diff --git a/Makefile b/Makefile index b8548e77d1..b0c067b3e9 100644 --- a/Makefile +++ b/Makefile @@ -1351,6 +1351,7 @@ BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS endif ifneq ($(filter leak,$(SANITIZERS)),) BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS +BASIC_CFLAGS += -O0 SANITIZE_LEAK = YesCompiledWithIt endif ifneq ($(filter address,$(SANITIZERS)),) diff --git a/diagnose.c b/diagnose.c index 52c4df114d..09515e39bb 100644 --- a/diagnose.c +++ b/diagnose.c @@ -322,6 +322,8 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode) } if (shared_cache) { + size_t path_len; + strbuf_reset(&buf); strbuf_addf(&path, "%s/pack", shared_cache); strbuf_reset(&buf); @@ -336,6 +338,8 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode) strbuf_reset(&path); strbuf_addf(&path, "%s/info", shared_cache); + path_len = path.len; + if (is_directory(path.buf)) { DIR *dir = opendir(path.buf); struct dirent *e; @@ -343,9 +347,16 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode) while ((e = readdir(dir))) { if (!strcmp(".", e->d_name) || !strcmp("..", e->d_name)) continue; + if (e->d_type == DT_DIR) + continue; strbuf_reset(&buf); strbuf_addf(&buf, "--add-virtual-file=info/%s:", e->d_name); + + strbuf_setlen(&path, path_len); + strbuf_addch(&path, '/'); + strbuf_addstr(&path, e->d_name); + if (strbuf_read_file(&buf, path.buf, 0) < 0) { res = error_errno(_("could not read '%s'"), path.buf); goto diagnose_cleanup; diff --git a/scalar.c b/scalar.c index 5a576392d2..9309fde68c 100644 --- a/scalar.c +++ b/scalar.c @@ -930,6 +930,8 @@ static int cmd_diagnose(int argc, const char **argv) setup_enlistment_directory(argc, argv, usage, options, &diagnostics_root); strbuf_addstr(&diagnostics_root, "/.scalarDiagnostics"); + /* Here, a failure should not repeat itself. */ + git_retries = 1; res = run_git("diagnose", "--mode=all", "-s", "%Y%m%d_%H%M%S", "-o", diagnostics_root.buf, NULL);