summaryrefslogtreecommitdiff
path: root/src/posix.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-03-09 19:55:50 +0100
committerVicent Martí <tanoku@gmail.com>2012-03-09 20:09:22 +0100
commitdda708e78f3c3f43d814d46c29ab9f2b9d47ed5c (patch)
tree60a6e01583c15209a42740a46e182ac7cbc893de /src/posix.c
parent6af24ce31f43c3621f11720704a078058665bc3f (diff)
downloadlibgit2-dda708e78f3c3f43d814d46c29ab9f2b9d47ed5c.tar.gz
error-handling: On-disk config file backend
Includes: - Proper error reporting when encountering syntax errors in a config file (file, line number, column). - Rewritten `config_write`, now with 99% less goto-spaghetti - Error state in `git_filebuf`: filebuf write functions no longer need to be checked for error returns. If any of the writes performed on a buffer fail, the last call to `git_filebuf_commit` or `git_filebuf_hash` will fail accordingly and set the appropiate error message. Baller!
Diffstat (limited to 'src/posix.c')
-rw-r--r--src/posix.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/posix.c b/src/posix.c
index d2364d9b4..9d96d3013 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -31,10 +31,9 @@ int p_getcwd(char *buffer_out, size_t size)
cwd_buffer = getcwd(buffer_out, size);
if (cwd_buffer == NULL)
- return git__throw(GIT_EOSERR, "Failed to retrieve current working directory");
+ return -1;
git_path_mkposix(buffer_out);
-
git_path_string_to_dir(buffer_out, size); //Ensure the path ends with a trailing slash
return GIT_SUCCESS;
@@ -44,14 +43,13 @@ int p_rename(const char *from, const char *to)
{
if (!link(from, to)) {
p_unlink(from);
- return GIT_SUCCESS;
+ return 0;
}
if (!rename(from, to))
- return GIT_SUCCESS;
-
- return GIT_ERROR;
+ return 0;
+ return -1;
}
#endif
@@ -64,7 +62,7 @@ int p_read(git_file fd, void *buf, size_t cnt)
if (r < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
- return GIT_EOSERR;
+ return -1;
}
if (!r)
break;
@@ -82,14 +80,14 @@ int p_write(git_file fd, const void *buf, size_t cnt)
if (r < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
- return GIT_EOSERR;
+ return -1;
}
if (!r) {
errno = EPIPE;
- return GIT_EOSERR;
+ return -1;
}
cnt -= r;
b += r;
}
- return GIT_SUCCESS;
+ return 0;
}