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
fac66990
Commit
fac66990
authored
Jun 05, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repository: make git_repository_init() value the core.filemode config entry
parent
01dbe273
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletions
+45
-1
src/repository.c
+23
-1
src/win32/msvc-compat.h
+1
-0
tests-clar/repo/init.c
+21
-0
No files found.
src/repository.c
View file @
fac66990
...
...
@@ -655,6 +655,27 @@ static int repo_init_createhead(const char *git_dir)
return
0
;
}
static
bool
is_chmod_supported
(
const
char
*
file_path
)
{
struct
stat
st1
,
st2
;
static
int
_is_supported
=
-
1
;
if
(
_is_supported
>
-
1
)
return
_is_supported
;
if
(
p_stat
(
file_path
,
&
st1
)
<
0
)
return
false
;
if
(
p_chmod
(
file_path
,
st1
.
st_mode
^
S_IXUSR
)
<
0
)
return
false
;
if
(
p_stat
(
file_path
,
&
st2
)
<
0
)
return
false
;
_is_supported
=
(
st1
.
st_mode
!=
st2
.
st_mode
);
return
_is_supported
;
}
static
int
repo_init_config
(
const
char
*
git_dir
,
int
is_bare
)
{
git_buf
cfg_path
=
GIT_BUF_INIT
;
...
...
@@ -670,13 +691,14 @@ static int repo_init_config(const char *git_dir, int is_bare)
if
(
git_buf_joinpath
(
&
cfg_path
,
git_dir
,
GIT_CONFIG_FILENAME_INREPO
)
<
0
)
return
-
1
;
if
(
git_config_open_ondisk
(
&
config
,
cfg_path
.
ptr
)
<
0
)
{
if
(
git_config_open_ondisk
(
&
config
,
git_buf_cstr
(
&
cfg_path
)
)
<
0
)
{
git_buf_free
(
&
cfg_path
);
return
-
1
;
}
SET_REPO_CONFIG
(
bool
,
"core.bare"
,
is_bare
);
SET_REPO_CONFIG
(
int32
,
"core.repositoryformatversion"
,
GIT_REPO_VERSION
);
SET_REPO_CONFIG
(
bool
,
"core.filemode"
,
is_chmod_supported
(
git_buf_cstr
(
&
cfg_path
)));
/* TODO: what other defaults? */
git_buf_free
(
&
cfg_path
);
...
...
src/win32/msvc-compat.h
View file @
fac66990
...
...
@@ -21,6 +21,7 @@
/* stat: file mode type testing macros */
# define _S_IFLNK 0120000
# define S_IFLNK _S_IFLNK
# define S_IXUSR 00100
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
...
...
tests-clar/repo/init.c
View file @
fac66990
...
...
@@ -165,3 +165,24 @@ void test_repo_init__additional_templates(void)
git_buf_free
(
&
path
);
}
void
test_repo_init__detect_filemode
(
void
)
{
git_config
*
config
;
int
filemode
;
cl_set_cleanup
(
&
cleanup_repository
,
"filemode"
);
cl_git_pass
(
git_repository_init
(
&
_repo
,
"filemode/filemode.git"
,
1
));
git_repository_config
(
&
config
,
_repo
);
cl_git_pass
(
git_config_get_bool
(
&
filemode
,
config
,
"core.filemode"
));
#ifdef GIT_WIN32
cl_assert_equal_i
(
false
,
filemode
);
#else
cl_assert_equal_i
(
true
,
filemode
);
#endif
git_config_free
(
config
);
}
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