}
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)
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)
* 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;
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;
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) {