Fix `scalar diagnose` failures (#543)

This resolves #541.

The root cause here is that this loop that intended to get all files
from the `info` directory of the shared object cache _never worked_, but
previously we did not propagate that to a complete failure.

The reason it didn't work is that we tried to read file contents from
the directory path.

I also noticed a silly retry issue because we are now using `run_git()`
which does three retries due to concurrency issues in the functional
tests. We don't want to repeat failures three times in `scalar
diagnose`.
This commit is contained in:
Derrick Stolee 2022-11-08 10:58:35 -05:00 коммит произвёл GitHub
Родитель 0de34d5468 cf052e5ce2
Коммит e380c61bc8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -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)),)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);