Skip to content

Commit

Permalink
refs.c: remove the_repo from read_ref_at()
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed Apr 8, 2019
1 parent 5670090 commit 7fdff47
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions builtin/show-branch.c
Expand Up @@ -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);
}
}
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions refs.c
Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion refs.h
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion sha1-name.c
Expand Up @@ -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/")) {
Expand Down

0 comments on commit 7fdff47

Please sign in to comment.