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
3ac05d11
Commit
3ac05d11
authored
Feb 17, 2017
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32: don't fsync parent directories on Windows
Windows doesn't support it.
parent
2a5ad7d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
src/fileops.c
+5
-0
tests/pack/packbuilder.c
+10
-1
tests/refs/create.c
+13
-2
No files found.
src/fileops.c
View file @
3ac05d11
...
...
@@ -1127,6 +1127,10 @@ void git_futils_filestamp_set_from_stat(
int
git_futils_fsync_dir
(
const
char
*
path
)
{
#ifdef GIT_WIN32
GIT_UNUSED
(
path
);
return
0
;
#else
int
fd
,
error
=
-
1
;
if
((
fd
=
p_open
(
path
,
O_RDONLY
))
<
0
)
{
...
...
@@ -1139,6 +1143,7 @@ int git_futils_fsync_dir(const char *path)
p_close
(
fd
);
return
error
;
#endif
}
int
git_futils_fsync_parent
(
const
char
*
path
)
...
...
tests/pack/packbuilder.c
View file @
3ac05d11
...
...
@@ -200,11 +200,20 @@ void test_pack_packbuilder__does_not_fsync_by_default(void)
void
test_pack_packbuilder__fsync_when_asked
(
void
)
{
/* We fsync the packfile and index. On non-Windows, we also fsync
* the parent directories.
*/
#ifdef GIT_WIN32
int
expected
=
2
;
#else
int
expected
=
4
;
#endif
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION
,
1
));
p_fsync__cnt
=
0
;
seed_packbuilder
();
git_packbuilder_write
(
_packbuilder
,
"."
,
0666
,
NULL
,
NULL
);
cl_assert_equal_sz
(
4
,
p_fsync__cnt
);
cl_assert_equal_sz
(
expected
,
p_fsync__cnt
);
}
static
int
foreach_cb
(
void
*
buf
,
size_t
len
,
void
*
payload
)
...
...
tests/refs/create.c
View file @
3ac05d11
...
...
@@ -323,13 +323,24 @@ void test_refs_create__fsyncs_when_requested(void)
git_refdb
*
refdb
;
git_oid
id
;
/* Creating a loose ref involves fsync'ing the reference, the
* reflog and (on non-Windows) the containing directories.
* Creating a packed ref involves fsync'ing the packed ref file
* and (on non-Windows) the containing directory.
*/
#ifdef GIT_WIN32
int
expected_create
=
2
,
expected_compress
=
1
;
#else
int
expected_create
=
4
,
expected_compress
=
2
;
#endif
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION
,
1
));
p_fsync__cnt
=
0
;
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_assert_equal_i
(
4
,
p_fsync__cnt
);
cl_assert_equal_i
(
expected_create
,
p_fsync__cnt
);
p_fsync__cnt
=
0
;
...
...
@@ -337,5 +348,5 @@ void test_refs_create__fsyncs_when_requested(void)
cl_git_pass
(
git_refdb_compress
(
refdb
));
git_refdb_free
(
refdb
);
cl_assert_equal_i
(
2
,
p_fsync__cnt
);
cl_assert_equal_i
(
expected_compress
,
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