refs.c: remove the_repo from read_ref_at()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2019-04-06 18:34:30 +07:00 committed by Junio C Hamano
parent 567009033f
commit 7fdff47432
4 changed files with 12 additions and 7 deletions

View File

@ -753,7 +753,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
/* Ah, that is a date spec... */
timestamp_t at;
at = approxidate(reflog_base);
read_ref_at(ref, flags, at, -1, &oid, NULL,
read_ref_at(get_main_ref_store(the_repository),
ref, flags, at, -1, &oid, NULL,
NULL, NULL, &base);
}
}
@ -765,7 +766,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
timestamp_t timestamp;
int tz;
if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg,
if (read_ref_at(get_main_ref_store(the_repository),
ref, flags, 0, base + i, &oid, &logmsg,
&timestamp, &tz, NULL)) {
reflog = i;
break;

7
refs.c
View File

@ -967,7 +967,8 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid
return 1;
}
int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, int cnt,
int read_ref_at(struct ref_store *refs, const char *refname,
unsigned int flags, timestamp_t at_time, int cnt,
struct object_id *oid, char **msg,
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
{
@ -983,7 +984,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in
cb.cutoff_cnt = cutoff_cnt;
cb.oid = oid;
for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);
refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent, &cb);
if (!cb.reccnt) {
if (flags & GET_OID_QUIETLY)
@ -994,7 +995,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in
if (cb.found_it)
return 0;
for_each_reflog_ent(refname, read_ref_at_ent_oldest, &cb);
refs_for_each_reflog_ent(refs, refname, read_ref_at_ent_oldest, &cb);
return 1;
}

3
refs.h
View File

@ -388,7 +388,8 @@ int refs_create_reflog(struct ref_store *refs, const char *refname,
int safe_create_reflog(const char *refname, int force_create, struct strbuf *err);
/** Reads log for the value of ref during at_time. **/
int read_ref_at(const char *refname, unsigned int flags,
int read_ref_at(struct ref_store *refs,
const char *refname, unsigned int flags,
timestamp_t at_time, int cnt,
struct object_id *oid, char **msg,
timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);

View File

@ -849,7 +849,8 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
return -1;
}
}
if (read_ref_at(real_ref, flags, at_time, nth, oid, NULL,
if (read_ref_at(get_main_ref_store(the_repository),
real_ref, flags, at_time, nth, oid, NULL,
&co_time, &co_tz, &co_cnt)) {
if (!len) {
if (starts_with(real_ref, "refs/heads/")) {