diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2012-07-02 17:51:02 +0200 |
|---|---|---|
| committer | nulltoken <emeric.fermas@gmail.com> | 2012-07-02 19:56:41 +0200 |
| commit | 494ae940a07831fd1ce318f6fd0f04738bfc2fe5 (patch) | |
| tree | a57f265ed24daf756c647e7fa6add783647276e1 /src/revparse.c | |
| parent | e560aa8ffa7cf143fbd34a5aec44741ae4c77271 (diff) | |
| download | libgit2-494ae940a07831fd1ce318f6fd0f04738bfc2fe5.tar.gz | |
revparse: fix parsing of date specifiers
Diffstat (limited to 'src/revparse.c')
| -rw-r--r-- | src/revparse.c | 23 |
1 files changed, 5 insertions, 18 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); |
