Commit 56d8ca26 by nulltoken Committed by Vicent Marti

Switch from time_t to git_time_t

git_time_t is defined as a signed 64 integer. This allows a true predictable multiplatform behavior.
parent fe192020
...@@ -83,7 +83,7 @@ GIT_EXTERN(const char *) git_commit_message(git_commit *commit); ...@@ -83,7 +83,7 @@ GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
* @param commit a previously loaded commit. * @param commit a previously loaded commit.
* @return the time of a commit * @return the time of a commit
*/ */
GIT_EXTERN(time_t) git_commit_time(git_commit *commit); GIT_EXTERN(git_time_t) git_commit_time(git_commit *commit);
/** /**
* Get the commit timezone offset (i.e. committer's preferred timezone) of a commit. * Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.
......
...@@ -47,7 +47,7 @@ GIT_BEGIN_DECL ...@@ -47,7 +47,7 @@ GIT_BEGIN_DECL
* @offset timezone offset in minutes for the time * @offset timezone offset in minutes for the time
* @return the new sig, NULl on out of memory * @return the new sig, NULl on out of memory
*/ */
GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, time_t time, int offset); GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, git_time_t time, int offset);
/** /**
* Create a copy of an existing signature. * Create a copy of an existing signature.
......
...@@ -52,12 +52,12 @@ GIT_BEGIN_DECL ...@@ -52,12 +52,12 @@ GIT_BEGIN_DECL
#if defined(_MSC_VER) #if defined(_MSC_VER)
typedef __int64 git_off_t; typedef __int64 git_off_t;
typedef __time64_t git_time_t; typedef __time64_t git_time_t;
#elif defined(__MINGW32__) #elif defined(__MINGW32__)
typedef off64_t git_off_t; typedef off64_t git_off_t;
typedef time_t git_time_t; typedef time64_t git_time_t;
#else /* POSIX */ #else /* POSIX */
...@@ -66,8 +66,8 @@ typedef time_t git_time_t; ...@@ -66,8 +66,8 @@ typedef time_t git_time_t;
* before us (directly or indirectly), they'll get 32 bit off_t in their client * before us (directly or indirectly), they'll get 32 bit off_t in their client
* app, even though /we/ define _FILE_OFFSET_BITS=64. * app, even though /we/ define _FILE_OFFSET_BITS=64.
*/ */
typedef long long git_off_t; typedef int64_t git_off_t;
typedef time_t git_time_t; typedef int64_t git_time_t;
#endif #endif
...@@ -129,7 +129,7 @@ typedef struct git_index git_index; ...@@ -129,7 +129,7 @@ typedef struct git_index git_index;
/** Time in a signature */ /** Time in a signature */
typedef struct git_time { typedef struct git_time {
time_t time; /** time in seconds from epoch */ git_time_t time; /** time in seconds from epoch */
int offset; /** timezone offset, in minutes */ int offset; /** timezone offset, in minutes */
} git_time; } git_time;
......
...@@ -315,7 +315,7 @@ GIT_COMMIT_GETTER(const git_signature *, author, commit->author) ...@@ -315,7 +315,7 @@ GIT_COMMIT_GETTER(const git_signature *, author, commit->author)
GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer) GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer)
GIT_COMMIT_GETTER(const char *, message, commit->message) GIT_COMMIT_GETTER(const char *, message, commit->message)
GIT_COMMIT_GETTER(const char *, message_short, commit->message_short) GIT_COMMIT_GETTER(const char *, message_short, commit->message_short)
GIT_COMMIT_GETTER(time_t, time, commit->committer->when.time) GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time)
GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset) GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset)
GIT_COMMIT_GETTER(unsigned int, parentcount, commit->parent_oids.length) GIT_COMMIT_GETTER(unsigned int, parentcount, commit->parent_oids.length)
......
...@@ -312,8 +312,8 @@ int git_index_add(git_index *index, const char *rel_path, int stage) ...@@ -312,8 +312,8 @@ int git_index_add(git_index *index, const char *rel_path, int stage)
memset(&entry, 0x0, sizeof(git_index_entry)); memset(&entry, 0x0, sizeof(git_index_entry));
entry.ctime.seconds = st.st_ctime; entry.ctime.seconds = (git_time_t)st.st_ctime;
entry.mtime.seconds = st.st_mtime; entry.mtime.seconds = (git_time_t)st.st_mtime;
/* entry.mtime.nanoseconds = st.st_mtimensec; */ /* entry.mtime.nanoseconds = st.st_mtimensec; */
/* entry.ctime.nanoseconds = st.st_ctimensec; */ /* entry.ctime.nanoseconds = st.st_ctimensec; */
entry.dev= st.st_rdev; entry.dev= st.st_rdev;
...@@ -491,10 +491,10 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe ...@@ -491,10 +491,10 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe
source = (const struct entry_short *)(buffer); source = (const struct entry_short *)(buffer);
dest->ctime.seconds = (time_t)ntohl(source->ctime.seconds); dest->ctime.seconds = (git_time_t)ntohl(source->ctime.seconds);
dest->ctime.nanoseconds = (time_t)ntohl(source->ctime.nanoseconds); dest->ctime.nanoseconds = ntohl(source->ctime.nanoseconds);
dest->mtime.seconds = (time_t)ntohl(source->mtime.seconds); dest->mtime.seconds = (git_time_t)ntohl(source->mtime.seconds);
dest->mtime.nanoseconds = (time_t)ntohl(source->mtime.nanoseconds); dest->mtime.nanoseconds = ntohl(source->mtime.nanoseconds);
dest->dev = ntohl(source->dev); dest->dev = ntohl(source->dev);
dest->ino = ntohl(source->ino); dest->ino = ntohl(source->ino);
dest->mode = ntohl(source->mode); dest->mode = ntohl(source->mode);
......
...@@ -93,7 +93,7 @@ struct pack_file { ...@@ -93,7 +93,7 @@ struct pack_file {
git_oid *bad_object_sha1; /* array of git_oid */ git_oid *bad_object_sha1; /* array of git_oid */
int index_version; int index_version;
time_t mtime; git_time_t mtime;
int pack_fd; int pack_fd;
unsigned pack_local:1, pack_keep:1; unsigned pack_local:1, pack_keep:1;
git_oid sha1; git_oid sha1;
...@@ -827,7 +827,7 @@ static int packfile_check(struct pack_file **pack_out, const char *path, int loc ...@@ -827,7 +827,7 @@ static int packfile_check(struct pack_file **pack_out, const char *path, int loc
*/ */
p->pack_size = (off_t)st.st_size; p->pack_size = (off_t)st.st_size;
p->pack_local = local; p->pack_local = local;
p->mtime = st.st_mtime; p->mtime = (git_time_t)st.st_mtime;
/* see if we can parse the sha1 oid in the packfile name */ /* see if we can parse the sha1 oid in the packfile name */
if (path_len < 40 || if (path_len < 40 ||
......
...@@ -38,7 +38,7 @@ void git_signature_free(git_signature *sig) ...@@ -38,7 +38,7 @@ void git_signature_free(git_signature *sig)
free(sig); free(sig);
} }
git_signature *git_signature_new(const char *name, const char *email, time_t time, int offset) git_signature *git_signature_new(const char *name, const char *email, git_time_t time, int offset)
{ {
git_signature *p = NULL; git_signature *p = NULL;
......
...@@ -366,7 +366,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit") ...@@ -366,7 +366,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit")
const git_signature *author, *committer; const git_signature *author, *committer;
const char *message, *message_short; const char *message, *message_short;
time_t commit_time; git_time_t commit_time;
unsigned int parents, p; unsigned int parents, p;
git_commit *parent; git_commit *parent;
......
...@@ -34,7 +34,7 @@ struct test_entry { ...@@ -34,7 +34,7 @@ struct test_entry {
unsigned int index; unsigned int index;
char path[128]; char path[128];
git_off_t file_size; git_off_t file_size;
time_t mtime; git_time_t mtime;
}; };
struct test_entry TEST_ENTRIES[] = { struct test_entry TEST_ENTRIES[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment