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
fc77891f
Commit
fc77891f
authored
Dec 13, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_filebuf: optionally fsync when committing
parent
a4b5ac64
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
src/filebuf.c
+8
-0
src/filebuf.h
+3
-1
No files found.
src/filebuf.c
View file @
fc77891f
...
...
@@ -291,6 +291,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
if
(
flags
&
GIT_FILEBUF_DO_NOT_BUFFER
)
file
->
do_not_buffer
=
true
;
if
(
flags
&
GIT_FILEBUF_FSYNC
)
file
->
do_fsync
=
true
;
file
->
buf_size
=
size
;
file
->
buf_pos
=
0
;
file
->
fd
=
-
1
;
...
...
@@ -425,6 +428,11 @@ int git_filebuf_commit(git_filebuf *file)
file
->
fd_is_open
=
false
;
if
(
file
->
do_fsync
&&
p_fsync
(
file
->
fd
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"failed to fsync '%s'"
,
file
->
path_lock
);
goto
on_error
;
}
if
(
p_close
(
file
->
fd
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"failed to close file at '%s'"
,
file
->
path_lock
);
goto
on_error
;
...
...
src/filebuf.h
View file @
fc77891f
...
...
@@ -20,7 +20,8 @@
#define GIT_FILEBUF_FORCE (1 << 3)
#define GIT_FILEBUF_TEMPORARY (1 << 4)
#define GIT_FILEBUF_DO_NOT_BUFFER (1 << 5)
#define GIT_FILEBUF_DEFLATE_SHIFT (6)
#define GIT_FILEBUF_FSYNC (1 << 6)
#define GIT_FILEBUF_DEFLATE_SHIFT (7)
#define GIT_FILELOCK_EXTENSION ".lock\0"
#define GIT_FILELOCK_EXTLENGTH 6
...
...
@@ -47,6 +48,7 @@ struct git_filebuf {
bool
created_lock
;
bool
did_rename
;
bool
do_not_buffer
;
bool
do_fsync
;
int
last_error
;
};
...
...
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