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
9f4e7c84
Commit
9f4e7c84
authored
Feb 25, 2016
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3638 from ethomson/nsec
USE_NSECS fixes
parents
0d9a7498
3d6a42d1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
20 deletions
+51
-20
CMakeLists.txt
+17
-9
src/fileops.c
+8
-9
src/index.c
+2
-2
src/unix/posix.h
+12
-0
src/win32/win32-compat.h
+3
-0
tests/index/nsec.c
+9
-0
No files found.
CMakeLists.txt
View file @
9f4e7c84
...
...
@@ -86,17 +86,21 @@ IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
OPTION
(
USE_OPENSSL
"Link with and use openssl library"
ON
)
ENDIF
()
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_atim
"sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_ATIM LANGUAGE C
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_atimespec
"sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_ATIMESPEC LANGUAGE C
)
IF
(
HAVE_STRUCT_STAT_ST_ATIM
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtim
"sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtimespec
"sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtime_nsec sys/stat.h
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C
)
IF
(
HAVE_STRUCT_STAT_ST_MTIM
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C
)
ELSEIF
(
HAVE_STRUCT_STAT_ST_
A
TIMESPEC
)
ELSEIF
(
HAVE_STRUCT_STAT_ST_
M
TIMESPEC
)
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtimespec.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C
)
ELSE
()
SET
(
HAVE_STRUCT_STAT_NSEC ON
)
ENDIF
()
IF
(
HAVE_STRUCT_STAT_NSEC OR WIN32
)
...
...
@@ -539,8 +543,12 @@ IF (USE_NSEC)
ADD_DEFINITIONS
(
-DGIT_USE_NSEC
)
ENDIF
()
IF
(
HAVE_STRUCT_STAT_ST_ATIMESPEC
)
ADD_DEFINITIONS
(
-DGIT_USE_STAT_ATIMESPEC
)
IF
(
HAVE_STRUCT_STAT_ST_MTIM
)
ADD_DEFINITIONS
(
-DGIT_USE_STAT_MTIM
)
ELSEIF
(
HAVE_STRUCT_STAT_ST_MTIMESPEC
)
ADD_DEFINITIONS
(
-DGIT_USE_STAT_MTIMESPEC
)
ELSEIF
(
HAVE_STRUCT_STAT_ST_MTIME_NSEC
)
ADD_DEFINITIONS
(
-DGIT_USE_STAT_MTIME_NSEC
)
ENDIF
()
ADD_DEFINITIONS
(
-D_FILE_OFFSET_BITS=64
)
...
...
src/fileops.c
View file @
9f4e7c84
...
...
@@ -1034,7 +1034,6 @@ int git_futils_filestamp_check(
git_futils_filestamp
*
stamp
,
const
char
*
path
)
{
struct
stat
st
;
const
struct
timespec
*
statmtime
=
&
st
.
st_mtim
;
/* if the stamp is NULL, then always reload */
if
(
stamp
==
NULL
)
...
...
@@ -1043,17 +1042,17 @@ int git_futils_filestamp_check(
if
(
p_stat
(
path
,
&
st
)
<
0
)
return
GIT_ENOTFOUND
;
if
(
stamp
->
mtime
.
tv_sec
==
st
atmtime
->
tv_sec
&&
if
(
stamp
->
mtime
.
tv_sec
==
st
.
st_mtime
&&
#if defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_nsec
==
st
atmtime
->
tv
_nsec
&&
stamp
->
mtime
.
tv_nsec
==
st
.
st_mtime
_nsec
&&
#endif
stamp
->
size
==
(
git_off_t
)
st
.
st_size
&&
stamp
->
ino
==
(
unsigned
int
)
st
.
st_ino
)
return
0
;
stamp
->
mtime
.
tv_sec
=
st
atmtime
->
tv_sec
;
stamp
->
mtime
.
tv_sec
=
st
.
st_mtime
;
#if defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_nsec
=
st
atmtime
->
tv
_nsec
;
stamp
->
mtime
.
tv_nsec
=
st
.
st_mtime
_nsec
;
#endif
stamp
->
size
=
(
git_off_t
)
st
.
st_size
;
stamp
->
ino
=
(
unsigned
int
)
st
.
st_ino
;
...
...
@@ -1076,11 +1075,11 @@ void git_futils_filestamp_set(
void
git_futils_filestamp_set_from_stat
(
git_futils_filestamp
*
stamp
,
struct
stat
*
st
)
{
const
struct
timespec
*
statmtime
=
&
st
->
st_mtim
;
if
(
st
)
{
stamp
->
mtime
=
*
statmtime
;
#if !defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_sec
=
st
->
st_mtime
;
#if defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_nsec
=
st
->
st_mtime_nsec
;
#else
stamp
->
mtime
.
tv_nsec
=
0
;
#endif
stamp
->
size
=
(
git_off_t
)
st
->
st_size
;
...
...
src/index.c
View file @
9f4e7c84
...
...
@@ -829,8 +829,8 @@ void git_index_entry__init_from_stat(
entry
->
ctime
.
seconds
=
(
int32_t
)
st
->
st_ctime
;
entry
->
mtime
.
seconds
=
(
int32_t
)
st
->
st_mtime
;
#if defined(GIT_USE_NSEC)
entry
->
mtime
.
nanoseconds
=
st
->
st_mtim
.
tv
_nsec
;
entry
->
ctime
.
nanoseconds
=
st
->
st_ctim
.
tv
_nsec
;
entry
->
mtime
.
nanoseconds
=
st
->
st_mtim
e
_nsec
;
entry
->
ctime
.
nanoseconds
=
st
->
st_ctim
e
_nsec
;
#endif
entry
->
dev
=
st
->
st_rdev
;
entry
->
ino
=
st
->
st_ino
;
...
...
src/unix/posix.h
View file @
9f4e7c84
...
...
@@ -21,6 +21,18 @@ typedef int GIT_SOCKET;
#define p_lstat(p,b) lstat(p,b)
#define p_stat(p,b) stat(p, b)
#if defined(GIT_USE_STAT_MTIMESPEC)
# define st_atime_nsec st_atimespec.tv_nsec
# define st_mtime_nsec st_mtimespec.tv_nsec
# define st_ctime_nsec st_ctimespec.tv_nsec
#elif defined(GIT_USE_STAT_MTIM)
# define st_atime_nsec st_atim.tv_nsec
# define st_mtime_nsec st_mtim.tv_nsec
# define st_ctime_nsec st_ctim.tv_nsec
#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NEC)
# error GIT_USE_NSEC defined but unknown struct stat nanosecond type
#endif
#define p_utimes(f, t) utimes(f, t)
#define p_readlink(a, b, c) readlink(a, b, c)
...
...
src/win32/win32-compat.h
View file @
9f4e7c84
...
...
@@ -42,6 +42,9 @@ struct p_stat {
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_atime_nsec st_atim.tv_nsec
#define st_mtime_nsec st_mtim.tv_nsec
#define st_ctime_nsec st_ctim.tv_nsec
};
#define stat p_stat
...
...
tests/index/nsec.c
View file @
9f4e7c84
...
...
@@ -61,8 +61,17 @@ void test_index_nsec__staging_maintains_other_nanos(void)
cl_assert_equal_b
(
true
,
has_nsecs
());
cl_assert
((
entry
=
git_index_get_bypath
(
repo_index
,
"a.txt"
,
0
)));
/* if we are writing nanoseconds to the index, expect them to be
* nonzero. if we are *not*, expect that we truncated the entry.
*/
#ifdef GIT_USE_NSEC
cl_assert
(
entry
->
ctime
.
nanoseconds
!=
0
);
cl_assert
(
entry
->
mtime
.
nanoseconds
!=
0
);
#else
cl_assert_equal_i
(
0
,
entry
->
ctime
.
nanoseconds
);
cl_assert_equal_i
(
0
,
entry
->
mtime
.
nanoseconds
);
#endif
}
void
test_index_nsec__status_doesnt_clear_nsecs
(
void
)
...
...
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