git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jorge <griffin@gmx.es>, git@vger.kernel.org
Subject: Re: Bug: .gitconfig folder
Date: Wed, 27 May 2015 18:18:13 -0400	[thread overview]
Message-ID: <20150527221813.GF23259@peff.net> (raw)
In-Reply-To: <xmqq7frtlq56.fsf@gitster.dls.corp.google.com>

On Wed, May 27, 2015 at 01:30:29PM -0700, Junio C Hamano wrote:

> Jorge <griffin@gmx.es> writes:
> 
> > If you have a folder named ~/.gitconfig instead of a file with that
> > name, when you try to run some global config editing command it will
> > fail with a wrong error message:
> >
> >     "fatal: Out of memory? mmap failed: No such device"
> 
> That indeed is a funny error message.
> 
> How about this patch?
> 
> -- >8 --
> We show that message with die_errno(), but the OS is ought to know
> why mmap(2) failed much better than we do.  There is no reason for
> us to say "Out of memory?" here.
> 
> Note that mmap(2) fails with ENODEV when the file you specify is not
> something that can be mmap'ed, so you still need to know that "No
> such device" can include cases like having a directory when a
> regular file is expected, but we can expect that a user who creates
> a directory to a location where a regular file is expected to be
> would know what s/he is doing, hopefully ;-)
> 
>  sha1_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sha1_file.c b/sha1_file.c
> index ccc6dac..551a9e9 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -720,7 +720,7 @@ void *xmmap(void *start, size_t length,
>  		release_pack_memory(length);
>  		ret = mmap(start, length, prot, flags, fd, offset);
>  		if (ret == MAP_FAILED)
> -			die_errno("Out of memory? mmap failed");
> +			die_errno("mmap failed");
>  	}

This is definitely an improvement, but the real failing of that error
message is that it does not tell us that "~/.gitconfig" is the culprit.
I don't think we can do much from xmmap, though; it does not have the
filename. It would be nice if we got EISDIR from open() in the first
place, but I don't think we can implement that efficiently (if we added
an "xopen" that checked that, it would have to stat() every file we
opened).

-Peff

  reply	other threads:[~2015-05-27 22:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 13:29 Bug: .gitconfig folder Jorge
2015-05-27 20:30 ` Junio C Hamano
2015-05-27 22:18   ` Jeff King [this message]
2015-05-27 22:24     ` Stefan Beller
2015-05-28  6:13       ` Jeff King
2015-05-27 22:38     ` Junio C Hamano
2015-05-28  7:51       ` Jeff King
2015-05-28  7:54         ` [PATCH 1/4] read-cache.c: drop PROT_WRITE from mmap of index Jeff King
2015-05-28  7:54         ` [PATCH 2/4] config.c: fix mmap leak when writing config Jeff King
2015-06-30 14:34           ` [PATCH] config.c: fix writing config files on Windows network shares Karsten Blees
2015-06-30 14:46             ` Torsten Bögershausen
2015-06-30 16:01               ` Jeff King
2015-06-30 14:52             ` Johannes Schindelin
2015-06-30 16:00             ` Jeff King
2015-05-28  7:56         ` [PATCH 3/4] config.c: avoid xmmap error messages Jeff King
2015-05-28  8:03         ` [PATCH 4/4] config.c: rewrite ENODEV into EISDIR when mmap fails Jeff King
2015-05-28 17:11           ` Junio C Hamano
2015-05-28 20:44             ` Jeff King
2015-05-28 21:11               ` Junio C Hamano
2015-05-28 17:06         ` Bug: .gitconfig folder Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150527221813.GF23259@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=griffin@gmx.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).