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
f966acd1
Commit
f966acd1
authored
Nov 04, 2013
by
Edward Thomson
Committed by
Edward Thomson
Nov 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take umask into account in filebuf_commit
parent
0e1115d2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
5 deletions
+43
-5
include/git2/odb_backend.h
+2
-2
src/filebuf.c
+5
-1
src/odb_loose.c
+2
-2
tests-clar/core/filebuf.c
+34
-0
No files found.
include/git2/odb_backend.h
View file @
f966acd1
...
...
@@ -50,8 +50,8 @@ GIT_EXTERN(int) git_odb_backend_loose(
const
char
*
objects_dir
,
int
compression_level
,
int
do_fsync
,
mode_
t
dir_mode
,
mode_
t
file_mode
);
unsigned
in
t
dir_mode
,
unsigned
in
t
file_mode
);
/**
* Create a backend out of a single packfile
...
...
src/filebuf.c
View file @
f966acd1
...
...
@@ -320,9 +320,13 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path, mode_t mode)
int
git_filebuf_commit
(
git_filebuf
*
file
,
mode_t
mode
)
{
mode_t
mask
;
/* temporary files cannot be committed */
assert
(
file
&&
file
->
path_original
);
p_umask
(
mask
=
p_umask
(
0
));
file
->
flush_mode
=
Z_FINISH
;
flush_buffer
(
file
);
...
...
@@ -338,7 +342,7 @@ int git_filebuf_commit(git_filebuf *file, mode_t mode)
file
->
fd
=
-
1
;
if
(
p_chmod
(
file
->
path_lock
,
mode
))
{
if
(
p_chmod
(
file
->
path_lock
,
(
mode
&
~
mask
)
))
{
giterr_set
(
GITERR_OS
,
"Failed to set attributes for file at '%s'"
,
file
->
path_lock
);
goto
on_error
;
}
...
...
src/odb_loose.c
View file @
f966acd1
...
...
@@ -902,8 +902,8 @@ int git_odb_backend_loose(
const
char
*
objects_dir
,
int
compression_level
,
int
do_fsync
,
mode_
t
dir_mode
,
mode_
t
file_mode
)
unsigned
in
t
dir_mode
,
unsigned
in
t
file_mode
)
{
loose_backend
*
backend
;
size_t
objects_dirlen
;
...
...
tests-clar/core/filebuf.c
View file @
f966acd1
...
...
@@ -90,3 +90,37 @@ void test_core_filebuf__5(void)
cl_must_pass
(
p_unlink
(
test
));
}
/* make sure git_filebuf_commit takes umask into account */
void
test_core_filebuf__umask
(
void
)
{
git_filebuf
file
=
GIT_FILEBUF_INIT
;
char
test
[]
=
"test"
;
struct
stat
statbuf
;
mode_t
mask
,
os_mask
;
#ifdef GIT_WIN32
os_mask
=
0600
;
#else
os_mask
=
0777
;
#endif
p_umask
(
mask
=
p_umask
(
0
));
cl_assert
(
file
.
buffer
==
NULL
);
cl_git_pass
(
git_filebuf_open
(
&
file
,
test
,
0
));
cl_assert
(
file
.
buffer
!=
NULL
);
cl_git_pass
(
git_filebuf_printf
(
&
file
,
"%s
\n
"
,
"libgit2 rocks"
));
cl_assert
(
file
.
buffer
!=
NULL
);
cl_git_pass
(
git_filebuf_commit
(
&
file
,
0666
));
cl_assert
(
file
.
buffer
==
NULL
);
cl_must_pass
(
p_stat
(
"test"
,
&
statbuf
));
cl_assert_equal_i
(
statbuf
.
st_mode
&
os_mask
,
(
0666
&
~
mask
)
&
os_mask
);
cl_must_pass
(
p_unlink
(
test
));
}
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