mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 22:39:38 +00:00
Fix errors on Win32 with new repo init
This commit is contained in:
parent
c920e16232
commit
2eb4edf5f2
@ -604,7 +604,7 @@ static int _cp_r_callback(void *ref, git_buf *from)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (p_lstat(info->to.ptr, &to_st) < 0) {
|
if (p_lstat(info->to.ptr, &to_st) < 0) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT && errno != ENOTDIR) {
|
||||||
giterr_set(GITERR_OS,
|
giterr_set(GITERR_OS,
|
||||||
"Could not access %s while copying files", info->to.ptr);
|
"Could not access %s while copying files", info->to.ptr);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -914,17 +914,20 @@ static int repo_init_structure(
|
|||||||
mode_t dmode = pick_dir_mode(opts);
|
mode_t dmode = pick_dir_mode(opts);
|
||||||
|
|
||||||
/* Hide the ".git" directory */
|
/* Hide the ".git" directory */
|
||||||
if ((opts->flags & GIT_REPOSITORY_INIT_BARE) != 0) {
|
|
||||||
#ifdef GIT_WIN32
|
#ifdef GIT_WIN32
|
||||||
|
if ((opts->flags & GIT_REPOSITORY_INIT__HAS_DOTGIT) != 0) {
|
||||||
if (p_hide_directory__w32(repo_dir) < 0) {
|
if (p_hide_directory__w32(repo_dir) < 0) {
|
||||||
giterr_set(GITERR_REPOSITORY,
|
giterr_set(GITERR_REPOSITORY,
|
||||||
"Failed to mark Git repository folder as hidden");
|
"Failed to mark Git repository folder as hidden");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/* Create .git gitlink if appropriate */
|
#endif
|
||||||
else if ((opts->flags & GIT_REPOSITORY_INIT__NATURAL_WD) == 0) {
|
|
||||||
|
/* Create the .git gitlink if appropriate */
|
||||||
|
if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 &&
|
||||||
|
(opts->flags & GIT_REPOSITORY_INIT__NATURAL_WD) == 0)
|
||||||
|
{
|
||||||
if (repo_write_gitlink(work_dir, repo_dir) < 0)
|
if (repo_write_gitlink(work_dir, repo_dir) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,16 @@ static void cleanup_chmod_root(void *ref)
|
|||||||
git_futils_rmdir_r("r", GIT_DIRREMOVAL_EMPTY_HIERARCHY);
|
git_futils_rmdir_r("r", GIT_DIRREMOVAL_EMPTY_HIERARCHY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void check_mode(mode_t expected, mode_t actual)
|
||||||
|
{
|
||||||
|
#ifdef GIT_WIN32
|
||||||
|
/* chmod on Win32 doesn't support exec bit, not group/world bits */
|
||||||
|
cl_assert((expected & 0600) == (actual & 0777));
|
||||||
|
#else
|
||||||
|
cl_assert(expected == (actual & 0777));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void test_core_mkdir__chmods(void)
|
void test_core_mkdir__chmods(void)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -124,49 +134,49 @@ void test_core_mkdir__chmods(void)
|
|||||||
cl_git_pass(git_futils_mkdir("mode/is/important", "r", 0777, GIT_MKDIR_PATH));
|
cl_git_pass(git_futils_mkdir("mode/is/important", "r", 0777, GIT_MKDIR_PATH));
|
||||||
|
|
||||||
cl_git_pass(git_path_lstat("r/mode", &st));
|
cl_git_pass(git_path_lstat("r/mode", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode/is", &st));
|
cl_git_pass(git_path_lstat("r/mode/is", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode/is/important", &st));
|
cl_git_pass(git_path_lstat("r/mode/is/important", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
|
|
||||||
cl_git_pass(git_futils_mkdir("mode2/is2/important2", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD));
|
cl_git_pass(git_futils_mkdir("mode2/is2/important2", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD));
|
||||||
|
|
||||||
cl_git_pass(git_path_lstat("r/mode2", &st));
|
cl_git_pass(git_path_lstat("r/mode2", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode2/is2", &st));
|
cl_git_pass(git_path_lstat("r/mode2/is2", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode2/is2/important2", &st));
|
cl_git_pass(git_path_lstat("r/mode2/is2/important2", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
|
|
||||||
cl_git_pass(git_futils_mkdir("mode3/is3/important3", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH));
|
cl_git_pass(git_futils_mkdir("mode3/is3/important3", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH));
|
||||||
|
|
||||||
cl_git_pass(git_path_lstat("r/mode3", &st));
|
cl_git_pass(git_path_lstat("r/mode3", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode3/is3", &st));
|
cl_git_pass(git_path_lstat("r/mode3/is3", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode3/is3/important3", &st));
|
cl_git_pass(git_path_lstat("r/mode3/is3/important3", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
|
|
||||||
/* test that we chmod existing dir */
|
/* test that we chmod existing dir */
|
||||||
|
|
||||||
cl_git_pass(git_futils_mkdir("mode/is/important", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD));
|
cl_git_pass(git_futils_mkdir("mode/is/important", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD));
|
||||||
|
|
||||||
cl_git_pass(git_path_lstat("r/mode", &st));
|
cl_git_pass(git_path_lstat("r/mode", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode/is", &st));
|
cl_git_pass(git_path_lstat("r/mode/is", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0755);
|
check_mode(0755, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode/is/important", &st));
|
cl_git_pass(git_path_lstat("r/mode/is/important", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
|
|
||||||
/* test that we chmod even existing dirs if CHMOD_PATH is set */
|
/* test that we chmod even existing dirs if CHMOD_PATH is set */
|
||||||
|
|
||||||
cl_git_pass(git_futils_mkdir("mode2/is2/important2.1", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH));
|
cl_git_pass(git_futils_mkdir("mode2/is2/important2.1", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH));
|
||||||
|
|
||||||
cl_git_pass(git_path_lstat("r/mode2", &st));
|
cl_git_pass(git_path_lstat("r/mode2", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode2/is2", &st));
|
cl_git_pass(git_path_lstat("r/mode2/is2", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
cl_git_pass(git_path_lstat("r/mode2/is2/important2.1", &st));
|
cl_git_pass(git_path_lstat("r/mode2/is2/important2.1", &st));
|
||||||
cl_assert((st.st_mode & 0777) == 0777);
|
check_mode(0777, st.st_mode);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ static void ensure_repository_init(
|
|||||||
{
|
{
|
||||||
const char *workdir;
|
const char *workdir;
|
||||||
|
|
||||||
|
cl_assert(!git_path_isdir(working_directory));
|
||||||
|
|
||||||
cl_git_pass(git_repository_init(&_repo, working_directory, is_bare));
|
cl_git_pass(git_repository_init(&_repo, working_directory, is_bare));
|
||||||
|
|
||||||
workdir = git_repository_workdir(_repo);
|
workdir = git_repository_workdir(_repo);
|
||||||
@ -47,7 +49,8 @@ static void ensure_repository_init(
|
|||||||
|
|
||||||
#ifdef GIT_WIN32
|
#ifdef GIT_WIN32
|
||||||
if (!is_bare) {
|
if (!is_bare) {
|
||||||
cl_assert((GetFileAttributes(git_repository_path(_repo)) & FILE_ATTRIBUTE_HIDDEN) != 0);
|
DWORD fattrs = GetFileAttributes(git_repository_path(_repo));
|
||||||
|
cl_assert((fattrs & FILE_ATTRIBUTE_HIDDEN) != 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user