From: Alex Riesen <raa.lkml@gmail.com>
Date: Fri, 5 Dec 2008 00:36:46 +0000 (+0100)
Subject: Make chdir failures visible
X-Git-Tag: v1.6.1-rc2~8
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7be77de266b5cbcbd28d69a04df6f0b167b87cf6;p=git.git

Make chdir failures visible

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

diff --git a/git.c b/git.c
index 9e5813cc9..940a49896 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 78a8041ff..833ced226 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;