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

Re: Bug: .gitconfig folder

From
Junio C Hamano <gitster@pobox.com>
Date
May 27, 2015, 20:30 UTC
Message-ID
<xmqq7frtlq56.fsf@gitster.dls.corp.google.com>
In-Reply-To
<5565C6A7.60007@gmx.es>
Jorge <griffin@gmx.es> writes:
Show 5 quoted lines
> 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;
 }
Previous: JorgeNext: Jeff King
Message 2 of 20 in “Bug: .gitconfig folder”
  1. JorgeMay 27, 2015
  2. Junio C HamanoMay 27, 2015
  3. Jeff KingMay 27, 2015
  4. Stefan BellerMay 27, 2015
  5. Jeff KingMay 28, 2015
  6. Junio C HamanoMay 27, 2015
  7. Jeff KingMay 28, 2015
  8. 1/4 read-cache.c: drop PROT_WRITE from mmap of indexJeff King, May 28, 2015
  9. 2/4 config.c: fix mmap leak when writing configJeff King, May 28, 2015
  10. config.c: fix writing config files on Windows network sharesKarsten Blees, Jun 30, 2015
  11. Torsten BögershausenJun 30, 2015
  12. Jeff KingJun 30, 2015
  13. Johannes SchindelinJun 30, 2015
  14. Jeff KingJun 30, 2015
  15. 3/4 config.c: avoid xmmap error messagesJeff King, May 28, 2015
  16. 4/4 config.c: rewrite ENODEV into EISDIR when mmap failsJeff King, May 28, 2015
  17. Junio C HamanoMay 28, 2015
  18. Jeff KingMay 28, 2015
  19. Junio C HamanoMay 28, 2015
  20. Junio C HamanoMay 28, 2015

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.