warn_on_inaccessible(): a helper to warn on inaccessible paths

The previous series introduced warnings to multiple places, but it
could become tiring to see the warning on the same path over and
over again during a single run of Git.  Making just one function
responsible for issuing this warning, we could later choose to keep
track of which paths we issued a warning (it would involve a hash
table of paths after running them through real_path() or something)
in order to reduce noise.

Right now we do not know if the noise reduction is necessary, but it
still would be a good code reduction/sharing anyway.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2012-08-21 14:52:07 -07:00
parent 11e50b2736
commit 55b38a48e2
4 changed files with 11 additions and 3 deletions

2
attr.c
View File

@ -354,7 +354,7 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
if (!fp) {
if (errno != ENOENT)
warning(_("unable to access '%s': %s"), path, strerror(errno));
warn_on_inaccessible(path);
return NULL;
}
res = xcalloc(1, sizeof(*res));