git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: receive.denyNonNonFastForwards not denying force update

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 21, 2012, 16:50 UTC
Message-ID
<7v1uj0fauk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120821062219.GB26516@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 30 quoted lines
> On Tue, Aug 21, 2012 at 02:10:59AM -0400, Jeff King wrote:
>
>> I think that makes sense. Like this patch?
>> 
>> -- >8 --
>> Subject: [PATCH] config: warn on inaccessible files
>> 
>> Before reading a config file, we check "!access(path, R_OK)"
>> to make sure that the file exists and is readable. If it's
>> not, then we silently ignore it.
>> 
>> For the case of ENOENT, this is fine, as the presence of the
>> file is optional. For other cases, though, it may indicate a
>> configuration error (e.g., not having permissions to read
>> the file). Let's print a warning in these cases to let the
>> user know.
>
> And this might be a good follow-on:
>
> -- >8 --
> Subject: [PATCH] gitignore: report access errors of exclude files
>
> When we try to access gitignore files, we check for their
> existence with a call to "access". We silently ignore
> missing files. However, if a file is not readable, this may
> be a configuration error; let's warn the user.
>
> For $GIT_DIR/info/excludes or core.excludesfile, we can just
> use access_or_warn. However, for per-directory files we
> actually try to open them, so we must add a custom warning.

There are a couple of users of add_excludes_from_file() that is outside the per-directory walking in ls-files and unpack-trees; I think both are OK with this change, but the one in ls-files may want to issue a warning or even an error upon ENOENT.

Not a regression with this patch; just something we may want to do while we are in the vicinity.

Show 29 quoted lines
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  dir.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/dir.c b/dir.c
> index 240bf0c..4ee16b5 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -397,6 +397,8 @@ int add_excludes_from_file_to_list(const char *fname,
>  
>  	fd = open(fname, O_RDONLY);
>  	if (fd < 0 || fstat(fd, &st) < 0) {
> +		if (errno != ENOENT)
> +			warn(_("unable to access '%s': %s"), fname, strerror(errno));
>  		if (0 <= fd)
>  			close(fd);
>  		if (!check_index ||
> @@ -1311,9 +1313,9 @@ void setup_standard_excludes(struct dir_struct *dir)
>  		home_config_paths(NULL, &xdg_path, "ignore");
>  		excludes_file = xdg_path;
>  	}
> -	if (!access(path, R_OK))
> +	if (!access_or_warn(path, R_OK))
>  		add_excludes_from_file(dir, path);
> -	if (excludes_file && !access(excludes_file, R_OK))
> +	if (excludes_file && !access_or_warn(excludes_file, R_OK))
>  		add_excludes_from_file(dir, excludes_file);
>  }
Previous: Jeff KingNext: Jeff King
Message 14 of 20 in “receive.denyNonNonFastForwards not denying force update”
  1. John ArthorneAug 20, 2012
  2. Junio C HamanoAug 20, 2012
  3. Sitaram ChamartyAug 21, 2012
  4. Junio C HamanoAug 21, 2012
  5. Brandon CaseyAug 21, 2012
  6. Jay SoffianAug 21, 2012
  7. Junio C HamanoAug 21, 2012
  8. Jeff KingAug 21, 2012
  9. Junio C HamanoAug 21, 2012
  10. Jeff KingAug 21, 2012
  11. Jeff KingAug 21, 2012
  12. Jeff KingAug 21, 2012
  13. Jeff KingAug 21, 2012
  14. Junio C HamanoAug 21, 2012
  15. Jeff KingAug 21, 2012
  16. Junio C HamanoAug 21, 2012
  17. Junio C HamanoAug 21, 2012
  18. Jeff KingAug 21, 2012
  19. Sitaram ChamartyAug 21, 2012
  20. John ArthorneSep 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.