Skip to content

Commit 7be77de

Browse files
raalkmlgitster
authored andcommitted
Make chdir failures visible
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 47d32af commit 7be77de

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

git.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ static int handle_alias(int *argcp, const char ***argv)
195195
ret = 1;
196196
}
197197

198-
if (subdir)
199-
chdir(subdir);
198+
if (subdir && chdir(subdir))
199+
die("Cannot change to %s: %s", subdir, strerror(errno));
200200

201201
errno = saved_errno;
202202

setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
470470
}
471471
die("Not a git repository");
472472
}
473-
chdir("..");
473+
if (chdir(".."))
474+
die("Cannot change to %s/..: %s", cwd, strerror(errno));
474475
}
475476

476477
inside_git_dir = 0;

0 commit comments

Comments
 (0)