Make chdir failures visible
authorAlex Riesen <raa.lkml@gmail.com>
Fri, 5 Dec 2008 00:36:46 +0000 (01:36 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Dec 2008 02:05:51 +0000 (18:05 -0800)
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
setup.c

diff --git a/git.c b/git.c
index 9e5813cc92ebcaad6485091a24903bf14427ec57..940a498962ceb06a1dba85547d61ad62bb81a499 100644 (file)
--- 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 78a8041ff0d17a5220133549880ccbc507b1890d..833ced2269ae45b08f381fb2644b74f47cf50d1a 100644 (file)
--- 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;