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>
Nguyễn Thái Ngọc Duy committed
Apr 16, 2019 at 16:33 UTC
23a57129389b945f4bcecb5e99b2e03a4522be1b
1 file changed
+10
-7
sha1-name.c
+10
-7
@@ -771,7 +771,7 @@ static inline int push_mark(const char *string, int len)
771
}
772
773
static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags);
774
-static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf);
774
+static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf);
775
776
static int get_oid_basic(const char *str, int len, struct object_id *oid,
777
unsigned int flags)
@@ -835,7 +835,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
835
struct strbuf buf = STRBUF_INIT;
836
int detached;
837
838
- if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
838
+ if (interpret_nth_prior_checkout(the_repository, str, len, &buf) > 0) {
839
detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
840
strbuf_release(&buf);
841
if (detached)
@@ -1288,7 +1288,8 @@ static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid
1288
* Parse @{-N} syntax, return the number of characters parsed
1289
* if successful; otherwise signal an error with negative value.
1290
*/
1291
-static int interpret_nth_prior_checkout(const char *name, int namelen,
1291
+static int interpret_nth_prior_checkout(struct repository *r,
1292
+ const char *name, int namelen,
1293
struct strbuf *buf)
1294
{
1295
long nth;
@@ -1312,12 +1313,14 @@ static int interpret_nth_prior_checkout(const char *name, int namelen,
1313
cb.remaining = nth;
1314
strbuf_init(&cb.buf, 20);
1315
1315
- retval = 0;
1316
- if (0 < for_each_reflog_ent_reverse("HEAD", grab_nth_branch_switch, &cb)) {
1316
+ retval = refs_for_each_reflog_ent_reverse(get_main_ref_store(r),
1317
+ "HEAD", grab_nth_branch_switch, &cb);
1318
+ if (0 < retval) {
1319
strbuf_reset(buf);
1320
strbuf_addbuf(buf, &cb.buf);
1321
retval = brace - name + 1;
1320
- }
1322
+ } else
1323
+ retval = 0;
1324
1325
strbuf_release(&cb.buf);
1326
return retval;
@@ -1484,7 +1487,7 @@ int repo_interpret_branch_name(struct repository *r,
1487
namelen = strlen(name);
1488
1489
if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) {
1487
- len = interpret_nth_prior_checkout(name, namelen, buf);
1490
+ len = interpret_nth_prior_checkout(the_repository, name, namelen, buf);
1491
if (!len) {
1492
return len; /* syntax Ok, not enough switches */
1493
} else if (len > 0) {