sha1-name.c: add repo_interpret_branch_name()
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
71588ed2c020b157a98882bc9e455841935cfcfa
1 file changed
+8
-9
sha1-name.c
+8
-9
@@ -1390,7 +1390,8 @@ static int interpret_empty_at(const char *name, int namelen, int len, struct str
1390
return 1;
1391
}
1392
1393
-static int reinterpret(const char *name, int namelen, int len,
1393
+static int reinterpret(struct repository *r,
1394
+ const char *name, int namelen, int len,
1395
struct strbuf *buf, unsigned allowed)
1396
{
1397
/* we have extra data, which might need further processing */
@@ -1399,7 +1400,7 @@ static int reinterpret(const char *name, int namelen, int len,
1400
int ret;
1401
1402
strbuf_add(buf, name + len, namelen - len);
1402
- ret = interpret_branch_name(buf->buf, buf->len, &tmp, allowed);
1403
+ ret = repo_interpret_branch_name(r, buf->buf, buf->len, &tmp, allowed);
1404
/* that data was not interpreted, remove our cruft */
1405
if (ret < 0) {
1406
strbuf_setlen(buf, used);
@@ -1482,20 +1483,18 @@ int repo_interpret_branch_name(struct repository *r,
1483
const char *start;
1484
int len;
1485
1485
- if (r != the_repository)
1486
- BUG("interpret_branch_name() does not really use 'r' yet");
1486
if (!namelen)
1487
namelen = strlen(name);
1488
1489
if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) {
1491
- len = interpret_nth_prior_checkout(the_repository, name, namelen, buf);
1490
+ len = interpret_nth_prior_checkout(r, name, namelen, buf);
1491
if (!len) {
1492
return len; /* syntax Ok, not enough switches */
1493
} else if (len > 0) {
1494
if (len == namelen)
1495
return len; /* consumed all */
1496
else
1498
- return reinterpret(name, namelen, len, buf, allowed);
1497
+ return reinterpret(r, name, namelen, len, buf, allowed);
1498
}
1499
}
1500
@@ -1506,17 +1505,17 @@ int repo_interpret_branch_name(struct repository *r,
1505
if (!allowed || (allowed & INTERPRET_BRANCH_HEAD)) {
1506
len = interpret_empty_at(name, namelen, at - name, buf);
1507
if (len > 0)
1509
- return reinterpret(name, namelen, len, buf,
1508
+ return reinterpret(r, name, namelen, len, buf,
1509
allowed);
1510
}
1511
1513
- len = interpret_branch_mark(the_repository, name, namelen, at - name, buf,
1512
+ len = interpret_branch_mark(r, name, namelen, at - name, buf,
1513
upstream_mark, branch_get_upstream,
1514
allowed);
1515
if (len > 0)
1516
return len;
1517
1519
- len = interpret_branch_mark(the_repository, name, namelen, at - name, buf,
1518
+ len = interpret_branch_mark(r, name, namelen, at - name, buf,
1519
push_mark, branch_get_push,
1520
allowed);
1521
if (len > 0)