summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-02-23 03:39:11 -0800
committerVicent Martí <vicent@github.com>2013-02-23 03:39:11 -0800
commit5eeb357df806a60664f61bf1238a21a402732c44 (patch)
tree2c738d40a29477f6fd5ac477e76be292ff2b4be9 /src
parent68fec637a24fa60497e458155432c76327b60653 (diff)
parent6c72035fbc9688d52ccee47f3efb24913fc20af9 (diff)
downloadlibgit2-5eeb357df806a60664f61bf1238a21a402732c44.tar.gz
Merge pull request #1355 from phkelley/development
Portability fixes for Solaris
Diffstat (limited to 'src')
-rw-r--r--src/errors.c9
-rw-r--r--src/fileops.c38
2 files changed, 33 insertions, 14 deletions
diff --git a/src/errors.c b/src/errors.c
index 3aa1757b2..c5f0b3b59 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -89,15 +89,16 @@ void giterr_set_str(int error_class, const char *string)
int giterr_set_regex(const regex_t *regex, int error_code)
{
char error_buf[1024];
+
+ assert(error_code);
+
regerror(error_code, regex, error_buf, sizeof(error_buf));
giterr_set_str(GITERR_REGEX, error_buf);
if (error_code == REG_NOMATCH)
return GIT_ENOTFOUND;
- else if (error_code > REG_BADPAT)
- return GIT_EINVALIDSPEC;
- else
- return -1;
+
+ return GIT_EINVALIDSPEC;
}
void giterr_clear(void)
diff --git a/src/fileops.c b/src/fileops.c
index 4ae9e3ab1..3531e75b8 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -300,25 +300,43 @@ int git_futils_mkdir(
/* make directory */
if (p_mkdir(make_path.ptr, mode) < 0) {
- if (errno == EEXIST) {
- if (!lastch && (flags & GIT_MKDIR_VERIFY_DIR) != 0) {
- if (!git_path_isdir(make_path.ptr)) {
+ int already_exists = 0;
+
+ switch (errno) {
+ case EEXIST:
+ if (!lastch && (flags & GIT_MKDIR_VERIFY_DIR) != 0 &&
+ !git_path_isdir(make_path.ptr)) {
giterr_set(
GITERR_OS, "Existing path is not a directory '%s'",
make_path.ptr);
error = GIT_ENOTFOUND;
goto fail;
}
- }
- if ((flags & GIT_MKDIR_EXCL) != 0) {
- giterr_set(GITERR_OS, "Directory already exists '%s'",
+
+ already_exists = 1;
+ break;
+ case ENOSYS:
+ /* Solaris can generate this error if you try to mkdir
+ * a path which is already a mount point. In that case,
+ * the path does already exist; but it's not implied by
+ * the definition of the error, so let's recheck */
+ if (git_path_isdir(make_path.ptr)) {
+ already_exists = 1;
+ break;
+ }
+
+ /* Fall through */
+ errno = ENOSYS;
+ default:
+ giterr_set(GITERR_OS, "Failed to make directory '%s'",
make_path.ptr);
- error = GIT_EEXISTS;
goto fail;
- }
- } else {
- giterr_set(GITERR_OS, "Failed to make directory '%s'",
+ }
+
+ if (already_exists && (flags & GIT_MKDIR_EXCL) != 0) {
+ giterr_set(GITERR_OS, "Directory already exists '%s'",
make_path.ptr);
+ error = GIT_EEXISTS;
goto fail;
}
}