All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jorge <griffin@gmx.es>
Cc: git@vger.kernel.org
Subject: Re: Bug: .gitconfig folder
Date: Wed, 27 May 2015 13:30:29 -0700	[thread overview]
Message-ID: <xmqq7frtlq56.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <5565C6A7.60007@gmx.es> (Jorge's message of "Wed, 27 May 2015 15:29:11 +0200")

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");
 	}
 	return ret;
 }

  reply	other threads:[~2015-05-27 20:30 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 [this message]
2015-05-27 22:18   ` Jeff King
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=xmqq7frtlq56.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.