@matheusbsbs / matheus-bagliano / commits / 7be77de266
Fork 0

Make chdir failures visible

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

Alex Riesen committed Dec 5, 2008 at 01:36 UTC 7be77de266b5cbcbd28d69a04df6f0b167b87cf6
2 files changed +4 -3
git.c
+2 -2
@@ -195,8 +195,8 @@ static int handle_alias(int *argcp, const char ***argv)
195 ret = 1;
196 }
197
198 - if (subdir)
199 - chdir(subdir);
198 + if (subdir && chdir(subdir))
199 + die("Cannot change to %s: %s", subdir, strerror(errno));
200
201 errno = saved_errno;
202
setup.c
+2 -1
@@ -470,7 +470,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
470 }
471 die("Not a git repository");
472 }
473 - chdir("..");
473 + if (chdir(".."))
474 + die("Cannot change to %s/..: %s", cwd, strerror(errno));
475 }
476
477 inside_git_dir = 0;