summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-06-27 17:58:47 +0200
committerJunio C Hamano <gitster@pobox.com>2009-06-27 11:14:53 -0700
commit0721c314a5c8fddc877140ab5a333c42c62f780d (patch)
tree3fbea50f91636df092ac245284e811a32738842c /setup.c
parentd824cbba02a4061400a0e382f9bd241fbbff34f0 (diff)
downloadgit-0721c314a5c8fddc877140ab5a333c42c62f780d.tar.gz
Use die_errno() instead of die() when checking syscalls
Lots of die() calls did not actually report the kind of error, which can leave the user confused as to the real problem. Use die_errno() where we check a system/library call that sets errno on failure, or one of the following that wrap such calls: Function Passes on error from -------- -------------------- odb_pack_keep open read_ancestry fopen read_in_full xread strbuf_read xread strbuf_read_file open or strbuf_read_file strbuf_readlink readlink write_in_full xwrite Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/setup.c b/setup.c
index 4d27f28c8f..e3781b656d 100644
--- a/setup.c
+++ b/setup.c
@@ -327,7 +327,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
return NULL;
set_git_dir(make_absolute_path(gitdirenv));
if (chdir(work_tree_env) < 0)
- die ("Could not chdir to %s", work_tree_env);
+ die_errno ("Could not chdir to '%s'", work_tree_env);
strcat(buffer, "/");
return retval;
}
@@ -339,7 +339,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
}
if (!getcwd(cwd, sizeof(cwd)-1))
- die("Unable to read current working directory");
+ die_errno("Unable to read current working directory");
ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
@@ -382,7 +382,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
if (offset <= ceil_offset) {
if (nongit_ok) {
if (chdir(cwd))
- die("Cannot come back to cwd");
+ die_errno("Cannot come back to cwd");
*nongit_ok = 1;
return NULL;
}
@@ -493,10 +493,10 @@ const char *setup_git_directory(void)
static char buffer[PATH_MAX + 1];
char *rel;
if (retval && chdir(retval))
- die ("Could not jump back into original cwd");
+ die_errno ("Could not jump back into original cwd");
rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
if (rel && *rel && chdir(get_git_work_tree()))
- die ("Could not jump to working directory");
+ die_errno ("Could not jump to working directory");
return rel && *rel ? strcat(rel, "/") : NULL;
}