Skip to content

Commit ba307a5

Browse files
vdyegitster
authored andcommitted
scalar-diagnose: add directory to archiver more gently
If a directory added to the 'scalar diagnose' archiver does not exist, warn and return 0 from 'add_directory_to_archiver()' rather than failing with a fatal error. This handles a failure edge case where the '.git/logs' has not yet been created when running 'scalar diagnose', but extends to any situation where a directory may be missing in the '.git' dir. Now, when a directory is missing a warning is captured in the diagnostic logs. This provides a user with more complete information than if 'scalar diagnose' simply failed with an error. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91be401 commit ba307a5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

contrib/scalar/scalar.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,20 @@ static int add_directory_to_archiver(struct strvec *archiver_args,
266266
const char *path, int recurse)
267267
{
268268
int at_root = !*path;
269-
DIR *dir = opendir(at_root ? "." : path);
269+
DIR *dir;
270270
struct dirent *e;
271271
struct strbuf buf = STRBUF_INIT;
272272
size_t len;
273273
int res = 0;
274274

275-
if (!dir)
275+
dir = opendir(at_root ? "." : path);
276+
if (!dir) {
277+
if (errno == ENOENT) {
278+
warning(_("could not archive missing directory '%s'"), path);
279+
return 0;
280+
}
276281
return error_errno(_("could not open directory '%s'"), path);
282+
}
277283

278284
if (!at_root)
279285
strbuf_addf(&buf, "%s/", path);

0 commit comments

Comments
 (0)