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
eb56ed81
Commit
eb56ed81
authored
Dec 15, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refdb_fs: optionally fsync packed refs
parent
af3dcb0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
src/refdb_fs.c
+5
-2
tests/refs/create.c
+15
-0
No files found.
src/refdb_fs.c
View file @
eb56ed81
...
...
@@ -994,15 +994,18 @@ static int packed_write(refdb_fs_backend *backend)
{
git_sortedcache
*
refcache
=
backend
->
refcache
;
git_filebuf
pack_file
=
GIT_FILEBUF_INIT
;
int
error
;
int
error
,
open_flags
=
0
;
size_t
i
;
/* lock the cache to updates while we do this */
if
((
error
=
git_sortedcache_wlock
(
refcache
))
<
0
)
return
error
;
if
(
git_object__synchronized_writing
)
open_flags
=
GIT_FILEBUF_FSYNC
;
/* Open the file! */
if
((
error
=
git_filebuf_open
(
&
pack_file
,
git_sortedcache_path
(
refcache
),
0
,
GIT_PACKEDREFS_FILE_MODE
))
<
0
)
if
((
error
=
git_filebuf_open
(
&
pack_file
,
git_sortedcache_path
(
refcache
),
open_flags
,
GIT_PACKEDREFS_FILE_MODE
))
<
0
)
goto
fail
;
/* Packfiles have a header... apparently
...
...
tests/refs/create.c
View file @
eb56ed81
...
...
@@ -303,17 +303,24 @@ void test_refs_create__creating_a_loose_ref_with_invalid_windows_name(void)
void
test_refs_create__does_not_fsync_by_default
(
void
)
{
git_reference
*
ref
=
NULL
;
git_refdb
*
refdb
;
git_oid
id
;
git_oid_fromstr
(
&
id
,
current_master_tip
);
cl_git_pass
(
git_reference_create
(
&
ref
,
g_repo
,
"refs/heads/fsync_test"
,
&
id
,
0
,
"log message"
));
git_reference_free
(
ref
);
cl_git_pass
(
git_repository_refdb
(
&
refdb
,
g_repo
));
cl_git_pass
(
git_refdb_compress
(
refdb
));
git_refdb_free
(
refdb
);
cl_assert_equal_i
(
0
,
p_fsync__cnt
);
}
void
test_refs_create__fsyncs_when_requested
(
void
)
{
git_reference
*
ref
=
NULL
;
git_refdb
*
refdb
;
git_oid
id
;
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION
,
1
));
...
...
@@ -323,4 +330,12 @@ void test_refs_create__fsyncs_when_requested(void)
cl_git_pass
(
git_reference_create
(
&
ref
,
g_repo
,
"refs/heads/fsync_test"
,
&
id
,
0
,
"log message"
));
git_reference_free
(
ref
);
cl_assert_equal_i
(
2
,
p_fsync__cnt
);
p_fsync__cnt
=
0
;
cl_git_pass
(
git_repository_refdb
(
&
refdb
,
g_repo
));
cl_git_pass
(
git_refdb_compress
(
refdb
));
git_refdb_free
(
refdb
);
cl_assert_equal_i
(
1
,
p_fsync__cnt
);
}
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