vendor/libgit2/src/sysdir.c in rugged-0.27.10 vs vendor/libgit2/src/sysdir.c in rugged-0.27.10.1
- old
+ new
@@ -55,16 +55,16 @@
error = getpwuid_r(uid, &pwd, buf, buflen, &pwdptr);
buflen *= 2;
} while (error == ERANGE && buflen <= 8192);
if (error) {
- git_error_set(GIT_ERROR_OS, "failed to get passwd entry");
+ giterr_set(GITERR_OS, "failed to get passwd entry");
goto out;
}
if (!pwdptr) {
- git_error_set(GIT_ERROR_OS, "no passwd entry found for user");
+ giterr_set(GITERR_OS, "no passwd entry found for user");
goto out;
}
if ((error = git_buf_puts(out, pwdptr->pw_dir)) < 0)
goto out;
@@ -80,35 +80,25 @@
#ifdef GIT_WIN32
return git_win32__find_global_dirs(out);
#else
int error;
uid_t uid, euid;
- const char *sandbox_id;
uid = getuid();
euid = geteuid();
- /**
- * If APP_SANDBOX_CONTAINER_ID is set, we are running in a
- * sandboxed environment on macOS.
- */
- sandbox_id = getenv("APP_SANDBOX_CONTAINER_ID");
-
/*
* In case we are running setuid, use the configuration
* of the effective user.
- *
- * If we are running in a sandboxed environment on macOS,
- * we have to get the HOME dir from the password entry file.
*/
- if (!sandbox_id && uid == euid)
+ if (uid == euid)
error = git__getenv(out, "HOME");
else
error = get_passwd_home(out, euid);
if (error == GIT_ENOTFOUND) {
- git_error_clear();
+ giterr_clear();
error = 0;
}
return error;
#endif
@@ -140,15 +130,15 @@
if ((error = get_passwd_home(&env, euid)) == 0)
error = git_buf_joinpath(out, env.ptr, ".config/git");
}
if (error == GIT_ENOTFOUND) {
- git_error_clear();
+ giterr_clear();
error = 0;
}
- git_buf_dispose(&env);
+ git_buf_free(&env);
return error;
#endif
}
static int git_sysdir_guess_template_dirs(git_buf *out)
@@ -176,11 +166,11 @@
static void git_sysdir_global_shutdown(void)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(git_sysdir__dirs); ++i)
- git_buf_dispose(&git_sysdir__dirs[i].buf);
+ git_buf_free(&git_sysdir__dirs[i].buf);
}
int git_sysdir_global_init(void)
{
size_t i;
@@ -197,22 +187,22 @@
static int git_sysdir_check_selector(git_sysdir_t which)
{
if (which < ARRAY_SIZE(git_sysdir__dirs))
return 0;
- git_error_set(GIT_ERROR_INVALID, "config directory selector out of range");
+ giterr_set(GITERR_INVALID, "config directory selector out of range");
return -1;
}
int git_sysdir_get(const git_buf **out, git_sysdir_t which)
{
assert(out);
*out = NULL;
- GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
+ GITERR_CHECK_ERROR(git_sysdir_check_selector(which));
*out = &git_sysdir__dirs[which].buf;
return 0;
}
@@ -221,15 +211,15 @@
size_t outlen,
git_sysdir_t which)
{
const git_buf *path = NULL;
- GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
- GIT_ERROR_CHECK_ERROR(git_sysdir_get(&path, which));
+ GITERR_CHECK_ERROR(git_sysdir_check_selector(which));
+ GITERR_CHECK_ERROR(git_sysdir_get(&path, which));
if (!out || path->size >= outlen) {
- git_error_set(GIT_ERROR_NOMEMORY, "buffer is too short for the path");
+ giterr_set(GITERR_NOMEMORY, "buffer is too short for the path");
return GIT_EBUFS;
}
git_buf_copy_cstr(out, outlen, path);
return 0;
@@ -240,11 +230,11 @@
int git_sysdir_set(git_sysdir_t which, const char *search_path)
{
const char *expand_path = NULL;
git_buf merge = GIT_BUF_INIT;
- GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
+ GITERR_CHECK_ERROR(git_sysdir_check_selector(which));
if (search_path != NULL)
expand_path = strstr(search_path, PATH_MAGIC);
/* reset the default if this path has been cleared */
@@ -270,11 +260,11 @@
expand_path += strlen(PATH_MAGIC);
if (*expand_path)
git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, expand_path);
git_buf_swap(&git_sysdir__dirs[which].buf, &merge);
- git_buf_dispose(&merge);
+ git_buf_free(&merge);
done:
if (git_buf_oom(&git_sysdir__dirs[which].buf))
return -1;
@@ -289,11 +279,11 @@
{
size_t len;
const char *scan, *next = NULL;
const git_buf *syspath;
- GIT_ERROR_CHECK_ERROR(git_sysdir_get(&syspath, which));
+ GITERR_CHECK_ERROR(git_sysdir_get(&syspath, which));
if (!syspath || !git_buf_len(syspath))
goto done;
for (scan = git_buf_cstr(syspath); scan; scan = next) {
/* find unescaped separator or end of string */
@@ -306,20 +296,20 @@
len = (size_t)(next - scan);
next = (*next ? next + 1 : NULL);
if (!len)
continue;
- GIT_ERROR_CHECK_ERROR(git_buf_set(path, scan, len));
+ GITERR_CHECK_ERROR(git_buf_set(path, scan, len));
if (name)
- GIT_ERROR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name));
+ GITERR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name));
if (git_path_exists(path->ptr))
return 0;
}
done:
- git_buf_dispose(path);
- git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
+ git_buf_free(path);
+ giterr_set(GITERR_OS, "the %s file '%s' doesn't exist", label, name);
return GIT_ENOTFOUND;
}
int git_sysdir_find_system_file(git_buf *path, const char *filename)
{