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

[PATCH 2/3] Make chdir failures visible

From
Alex Riesen <raa.lkml@gmail.com>
Date
Dec 5, 2008, 00:36 UTC
Message-ID
<20081205003646.GB7294@blimp.localdomain>
In-Reply-To
<20081205003546.GA7294@blimp.localdomain>
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 git.c   |    4 ++--
 setup.c |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/git.c b/git.c
index 9e5813c..940a498 100644
--- a/git.c
+++ b/git.c
@@ -195,8 +195,8 @@ static int handle_alias(int *argcp, const char ***argv)
 		ret = 1;
 	}
 
-	if (subdir)
-		chdir(subdir);
+	if (subdir && chdir(subdir))
+		die("Cannot change to %s: %s", subdir, strerror(errno));
 
 	errno = saved_errno;
 
diff --git a/setup.c b/setup.c
index 78a8041..833ced2 100644
--- a/setup.c
+++ b/setup.c
@@ -470,7 +470,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			}
 			die("Not a git repository");
 		}
-		chdir("..");
+		if (chdir(".."))
+			die("Cannot change to %s/..: %s", cwd, strerror(errno));
 	}
 
 	inside_git_dir = 0;
-- 
1.6.1.rc1.29.gb140
Previous: Alex RiesenNext: Alex Riesen
Message 2 of 4 in “Make some of fwrite/fclose/write/close failures visible”
  1. 1/3 Make some of fwrite/fclose/write/close failures visibleAlex Riesen, Dec 5, 2008
  2. 2/3 Make chdir failures visibleAlex Riesen, Dec 5, 2008
  3. 3/3 Report symlink failures in merge-recursiveAlex Riesen, Dec 5, 2008
  4. Junio C HamanoDec 5, 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.