Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2eb4edf5
Commit
2eb4edf5
authored
Aug 24, 2012
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors on Win32 with new repo init
parent
c920e162
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
21 deletions
+37
-21
src/fileops.c
+1
-1
src/repository.c
+7
-4
tests-clar/core/mkdir.c
+25
-15
tests-clar/repo/init.c
+4
-1
No files found.
src/fileops.c
View file @
2eb4edf5
...
...
@@ -604,7 +604,7 @@ static int _cp_r_callback(void *ref, git_buf *from)
return
-
1
;
if
(
p_lstat
(
info
->
to
.
ptr
,
&
to_st
)
<
0
)
{
if
(
errno
!=
ENOENT
)
{
if
(
errno
!=
ENOENT
&&
errno
!=
ENOTDIR
)
{
giterr_set
(
GITERR_OS
,
"Could not access %s while copying files"
,
info
->
to
.
ptr
);
return
-
1
;
...
...
src/repository.c
View file @
2eb4edf5
...
...
@@ -914,17 +914,20 @@ static int repo_init_structure(
mode_t
dmode
=
pick_dir_mode
(
opts
);
/* Hide the ".git" directory */
if
((
opts
->
flags
&
GIT_REPOSITORY_INIT_BARE
)
!=
0
)
{
#ifdef GIT_WIN32
if
((
opts
->
flags
&
GIT_REPOSITORY_INIT__HAS_DOTGIT
)
!=
0
)
{
if
(
p_hide_directory__w32
(
repo_dir
)
<
0
)
{
giterr_set
(
GITERR_REPOSITORY
,
"Failed to mark Git repository folder as hidden"
);
return
-
1
;
}
#endif
}
/* Create .git gitlink if appropriate */
else
if
((
opts
->
flags
&
GIT_REPOSITORY_INIT__NATURAL_WD
)
==
0
)
{
#endif
/* 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
)
return
-
1
;
}
...
...
tests-clar/core/mkdir.c
View file @
2eb4edf5
...
...
@@ -111,6 +111,16 @@ static void cleanup_chmod_root(void *ref)
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
)
{
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_path_lstat
(
"r/mode"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode/is"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode/is/important"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_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_path_lstat
(
"r/mode2"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode2/is2"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode2/is2/important2"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_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_path_lstat
(
"r/mode3"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode3/is3"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode3/is3/important3"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
/* 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_path_lstat
(
"r/mode"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode/is"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0755
);
c
heck_mode
(
0755
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode/is/important"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
/* 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_path_lstat
(
"r/mode2"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode2/is2"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
cl_git_pass
(
git_path_lstat
(
"r/mode2/is2/important2.1"
,
&
st
));
c
l_assert
((
st
.
st_mode
&
0777
)
==
0777
);
c
heck_mode
(
0777
,
st
.
st_mode
);
}
tests-clar/repo/init.c
View file @
2eb4edf5
...
...
@@ -30,6 +30,8 @@ static void ensure_repository_init(
{
const
char
*
workdir
;
cl_assert
(
!
git_path_isdir
(
working_directory
));
cl_git_pass
(
git_repository_init
(
&
_repo
,
working_directory
,
is_bare
));
workdir
=
git_repository_workdir
(
_repo
);
...
...
@@ -47,7 +49,8 @@ static void ensure_repository_init(
#ifdef GIT_WIN32
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment