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

[PATCH 1/2] chdir after computing new cwd in check_repository_format_gently

From
DRDavid Reiss <dreiss@facebook.com>
Date
May 14, 2008, 05:45 UTC
Message-ID
<482A7C71.6050509@facebook.com>

In preparation for adding a check before the chdir. This should be a no-op because the cwd is not read in the interim and any nonlocal exits either chdir to an absolute path or die.

Signed-off-by: David Reiss <dreiss@facebook.com>
---
I sent this in a few weeks ago, but got no response.  Probably because I
messed up the formatting.  Hopefully I'm getting it right this time.
 setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index b8fd476..c54f2b6 100644
--- a/setup.c
+++ b/setup.c
@@ -443,7 +443,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			check_repository_format_gently(nongit_ok);
 			return NULL;
 		}
-		chdir("..");
 		do {
 			if (!offset) {
 				if (nongit_ok) {
@@ -455,6 +454,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 				die("Not a git repository");
 			}
 		} while (cwd[--offset] != '/');
+		chdir("..");
 	}
 
 	inside_git_dir = 0;
-- 
1.5.4
Next: Johannes Schindelin
Message 1 of 2 in “chdir after computing new cwd in check_repository_format_gently”
  1. 1/2 chdir after computing new cwd in check_repository_format_gentlyDavid Reiss, May 14, 2008
  2. Johannes SchindelinMay 14, 2008

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.