summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-03-20 18:36:25 +0100
committerVicent Marti <tanoku@gmail.com>2011-03-23 00:07:58 +0200
commit56d8ca266c92e51a1b38ac68b7aa6a24193f5812 (patch)
tree83e188bcb8d157cd10774ecaabe0a4a42561f5b6
parentfe1920206b7fb780486dcef14d0d6f01835b430d (diff)
downloadlibgit2-56d8ca266c92e51a1b38ac68b7aa6a24193f5812.tar.gz
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.
-rw-r--r--include/git2/commit.h2
-rw-r--r--include/git2/signature.h2
-rw-r--r--include/git2/types.h10
-rw-r--r--src/commit.c2
-rw-r--r--src/index.c12
-rw-r--r--src/odb_pack.c4
-rw-r--r--src/signature.c2
-rw-r--r--tests/t04-commit.c2
-rw-r--r--tests/t06-index.c2
9 files changed, 19 insertions, 19 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h
index ba18a5b3..8306eb15 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -83,7 +83,7 @@ GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
* @param commit a previously loaded 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.
diff --git a/include/git2/signature.h b/include/git2/signature.h
index 96275aa0..200397ab 100644
--- a/include/git2/signature.h
+++ b/include/git2/signature.h
@@ -47,7 +47,7 @@ GIT_BEGIN_DECL
* @offset timezone offset in minutes for the time
* @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.
diff --git a/include/git2/types.h b/include/git2/types.h
index 64f7fc72..db09f384 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -52,12 +52,12 @@ GIT_BEGIN_DECL
#if defined(_MSC_VER)
typedef __int64 git_off_t;
-typedef __time64_t git_time_t;
+typedef __time64_t git_time_t;
#elif defined(__MINGW32__)
typedef off64_t git_off_t;
-typedef time_t git_time_t;
+typedef time64_t git_time_t;
#else /* POSIX */
@@ -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
* app, even though /we/ define _FILE_OFFSET_BITS=64.
*/
-typedef long long git_off_t;
-typedef time_t git_time_t;
+typedef int64_t git_off_t;
+typedef int64_t git_time_t;
#endif
@@ -129,7 +129,7 @@ typedef struct git_index git_index;
/** Time in a signature */
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 */
} git_time;
diff --git a/src/commit.c b/src/commit.c
index d5d6ebd8..03b111da 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -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 char *, message, commit->message)
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(unsigned int, parentcount, commit->parent_oids.length)
diff --git a/src/index.c b/src/index.c
index 6a355e11..34208731 100644
--- a/src/index.c
+++ b/src/index.c
@@ -312,8 +312,8 @@ int git_index_add(git_index *index, const char *rel_path, int stage)
memset(&entry, 0x0, sizeof(git_index_entry));
- entry.ctime.seconds = st.st_ctime;
- entry.mtime.seconds = st.st_mtime;
+ entry.ctime.seconds = (git_time_t)st.st_ctime;
+ entry.mtime.seconds = (git_time_t)st.st_mtime;
/* entry.mtime.nanoseconds = st.st_mtimensec; */
/* entry.ctime.nanoseconds = st.st_ctimensec; */
entry.dev= st.st_rdev;
@@ -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);
- dest->ctime.seconds = (time_t)ntohl(source->ctime.seconds);
- dest->ctime.nanoseconds = (time_t)ntohl(source->ctime.nanoseconds);
- dest->mtime.seconds = (time_t)ntohl(source->mtime.seconds);
- dest->mtime.nanoseconds = (time_t)ntohl(source->mtime.nanoseconds);
+ dest->ctime.seconds = (git_time_t)ntohl(source->ctime.seconds);
+ dest->ctime.nanoseconds = ntohl(source->ctime.nanoseconds);
+ dest->mtime.seconds = (git_time_t)ntohl(source->mtime.seconds);
+ dest->mtime.nanoseconds = ntohl(source->mtime.nanoseconds);
dest->dev = ntohl(source->dev);
dest->ino = ntohl(source->ino);
dest->mode = ntohl(source->mode);
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 65210f0b..8c527bcf 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -93,7 +93,7 @@ struct pack_file {
git_oid *bad_object_sha1; /* array of git_oid */
int index_version;
- time_t mtime;
+ git_time_t mtime;
int pack_fd;
unsigned pack_local:1, pack_keep:1;
git_oid sha1;
@@ -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_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 */
if (path_len < 40 ||
diff --git a/src/signature.c b/src/signature.c
index 13816c39..41263760 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -38,7 +38,7 @@ void git_signature_free(git_signature *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;
diff --git a/tests/t04-commit.c b/tests/t04-commit.c
index 1140d331..e9284243 100644
--- a/tests/t04-commit.c
+++ b/tests/t04-commit.c
@@ -366,7 +366,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit")
const git_signature *author, *committer;
const char *message, *message_short;
- time_t commit_time;
+ git_time_t commit_time;
unsigned int parents, p;
git_commit *parent;
diff --git a/tests/t06-index.c b/tests/t06-index.c
index 19b4da5c..93ca2c04 100644
--- a/tests/t06-index.c
+++ b/tests/t06-index.c
@@ -34,7 +34,7 @@ struct test_entry {
unsigned int index;
char path[128];
git_off_t file_size;
- time_t mtime;
+ git_time_t mtime;
};
struct test_entry TEST_ENTRIES[] = {