summaryrefslogtreecommitdiff
path: root/sha1-name.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-04-16 16:33:26 +0700
committerJunio C Hamano <gitster@pobox.com>2019-04-16 18:56:52 +0900
commit23a57129389b945f4bcecb5e99b2e03a4522be1b (patch)
treeffe501833e93e0fc64cb2d93ce74b6e74567666c /sha1-name.c
parentc6c0235b15a7eb9aed3aac6b9974d992c12b7b50 (diff)
downloadgit-23a57129389b945f4bcecb5e99b2e03a4522be1b.tar.gz
sha1-name.c: remove the_repo from interpret_nth_prior_checkout()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-name.c')
-rw-r--r--sha1-name.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sha1-name.c b/sha1-name.c
index 2643b75b54..af8bf5b351 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -771,7 +771,7 @@ static inline int push_mark(const char *string, int len)
}
static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags);
-static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf);
+static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf);
static int get_oid_basic(const char *str, int len, struct object_id *oid,
unsigned int flags)
@@ -835,7 +835,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
struct strbuf buf = STRBUF_INIT;
int detached;
- if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
+ if (interpret_nth_prior_checkout(the_repository, str, len, &buf) > 0) {
detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
strbuf_release(&buf);
if (detached)
@@ -1288,7 +1288,8 @@ static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid
* Parse @{-N} syntax, return the number of characters parsed
* if successful; otherwise signal an error with negative value.
*/
-static int interpret_nth_prior_checkout(const char *name, int namelen,
+static int interpret_nth_prior_checkout(struct repository *r,
+ const char *name, int namelen,
struct strbuf *buf)
{
long nth;
@@ -1312,12 +1313,14 @@ static int interpret_nth_prior_checkout(const char *name, int namelen,
cb.remaining = nth;
strbuf_init(&cb.buf, 20);
- retval = 0;
- if (0 < for_each_reflog_ent_reverse("HEAD", grab_nth_branch_switch, &cb)) {
+ retval = refs_for_each_reflog_ent_reverse(get_main_ref_store(r),
+ "HEAD", grab_nth_branch_switch, &cb);
+ if (0 < retval) {
strbuf_reset(buf);
strbuf_addbuf(buf, &cb.buf);
retval = brace - name + 1;
- }
+ } else
+ retval = 0;
strbuf_release(&cb.buf);
return retval;
@@ -1484,7 +1487,7 @@ int repo_interpret_branch_name(struct repository *r,
namelen = strlen(name);
if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) {
- len = interpret_nth_prior_checkout(name, namelen, buf);
+ len = interpret_nth_prior_checkout(the_repository, name, namelen, buf);
if (!len) {
return len; /* syntax Ok, not enough switches */
} else if (len > 0) {