summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-07-02 17:51:02 +0200
committernulltoken <emeric.fermas@gmail.com>2012-07-02 19:56:41 +0200
commit494ae940a07831fd1ce318f6fd0f04738bfc2fe5 (patch)
treea57f265ed24daf756c647e7fa6add783647276e1 /src
parente560aa8ffa7cf143fbd34a5aec44741ae4c77271 (diff)
downloadlibgit2-494ae940a07831fd1ce318f6fd0f04738bfc2fe5.tar.gz
revparse: fix parsing of date specifiers
Diffstat (limited to 'src')
-rw-r--r--src/revparse.c23
-rw-r--r--src/util.h7
2 files changed, 5 insertions, 25 deletions
diff --git a/src/revparse.c b/src/revparse.c
index 774beef63..8c15f46c6 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -267,31 +267,18 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
int numentries = git_reflog_entrycount(reflog);
int i;
- /* TODO: clunky. Factor "now" into a utility */
- git_signature *sig;
- git_time as_of;
-
- git_signature_now(&sig, "blah", "blah");
- as_of = sig->when;
- git_signature_free(sig);
-
- as_of.time = (timestamp > 0)
- ? timestamp
- : sig->when.time + timestamp;
-
- for (i=numentries-1; i>0; i--) {
+ for (i = numentries - 1; i >= 0; i--) {
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i);
git_time commit_time = git_reflog_entry_committer(entry)->when;
- if (git__time_cmp(&commit_time, &as_of) <= 0 ) {
+ if (commit_time.time - timestamp <= 0) {
retcode = git_object_lookup(out, repo, git_reflog_entry_oidnew(entry), GIT_OBJ_ANY);
break;
}
}
- if (!i) {
- /* Didn't find a match. Use the oldest revision in the reflog. */
- const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, 0);
- retcode = git_object_lookup(out, repo, git_reflog_entry_oidnew(entry), GIT_OBJ_ANY);
+ if (i == -1) {
+ /* Didn't find a match */
+ retcode = GIT_ENOTFOUND;
}
git_reflog_free(reflog);
diff --git a/src/util.h b/src/util.h
index eed2bc80c..adc665027 100644
--- a/src/util.h
+++ b/src/util.h
@@ -209,13 +209,6 @@ GIT_INLINE(bool) git__isspace(int c)
return (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == '\v');
}
-GIT_INLINE(int) git__time_cmp(const git_time *a, const git_time *b)
-{
- /* Adjust for time zones. Times are in seconds, offsets are in minutes. */
- git_time_t adjusted_a = a->time + ((b->offset - a->offset) * 60);
- return (int)(adjusted_a - b->time);
-}
-
GIT_INLINE(bool) git__iswildcard(int c)
{
return (c == '*' || c == '?' || c == '[');