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

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

From
René Scharfe <l.s.r@web.de>
Date
Mar 17, 2017, 19:34 UTC
Message-ID
<f6588ace-eecc-118d-ef26-70bc21dcc4d4@web.de>
In-Reply-To
<7f25def4-9943-ae59-a649-b4348a79890e@web.de>
Am 15.03.2017 um 22:30 schrieb René Scharfe:
Show 11 quoted lines
> Am 15.03.2017 um 10:44 schrieb Zenobiusz Kunegunda:
>> $ git bisect bad
>> 7333ed1788b4f2b162a35003044d77a716732a1f is the first bad commit
>> commit 7333ed1788b4f2b162a35003044d77a716732a1f
>> Author: René Scharfe <l.s.r@web.de>
>> Date:   Mon Jul 28 20:26:40 2014 +0200
>>
>>     setup: convert setup_git_directory_gently_1 et al. to strbuf
> 
> That's what I half-suspected, and I think by now I got an idea.  Here's
> a test program:

And here's a patch for letting strbuf_getcwd() use the same getcwd(3) extension that pwd(1) uses. It avoids the need to guess the path's length and thus reduces the chance of stumbling over strange error codes. I wonder if it helps in your case.

René
---
 strbuf.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/strbuf.c b/strbuf.c
index ace58e7367..4c02801edd 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -442,6 +442,14 @@ int strbuf_getcwd(struct strbuf *sb)
 {
 	size_t oldalloc = sb->alloc;
 	size_t guessed_len = 128;
+	char *cwd;
+
+	cwd = getcwd(NULL, 0);
+	if (cwd) {
+		size_t len = strlen(cwd);
+		strbuf_attach(sb, cwd, len, len + 1);
+		return 0;
+	}
 
 	for (;; guessed_len *= 2) {
 		strbuf_grow(sb, guessed_len);
-- 
2.12.0
Previous: René ScharfeNext: Stefan Beller
Message 14 of 23 in “fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |”
  1. Zenobiusz KunegundaMar 6, 2017
  2. René ScharfeMar 8, 2017
  3. Zenobiusz KunegundaMar 9, 2017
  4. René ScharfeMar 11, 2017
  5. Zenobiusz KunegundaMar 13, 2017
  6. René ScharfeMar 13, 2017
  7. Zenobiusz KunegundaMar 14, 2017
  8. Zenobiusz KunegundaMar 13, 2017
  9. René ScharfeMar 13, 2017
  10. Zenobiusz KunegundaMar 14, 2017
  11. René ScharfeMar 14, 2017
  12. Zenobiusz KunegundaMar 15, 2017
  13. René ScharfeMar 15, 2017
  14. René ScharfeMar 17, 2017
  15. Stefan BellerMar 17, 2017
  16. René ScharfeMar 17, 2017
  17. Jeff KingMar 17, 2017
  18. René ScharfeMar 17, 2017
  19. Zenobiusz KunegundaMar 21, 2017
  20. René ScharfeMar 21, 2017
  21. Zenobiusz KunegundaMar 22, 2017
  22. Zenobiusz KunegundaMar 21, 2017
  23. Zenobiusz KunegundaMar 9, 2017

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.