1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 12:26:12 +02:00

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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2019-04-16 16:33:28 +07:00 committed by Junio C Hamano
parent ea1c873c7d
commit 71588ed2c0

View File

@ -1390,7 +1390,8 @@ static int interpret_empty_at(const char *name, int namelen, int len, struct str
return 1;
}
static int reinterpret(const char *name, int namelen, int len,
static int reinterpret(struct repository *r,
const char *name, int namelen, int len,
struct strbuf *buf, unsigned allowed)
{
/* we have extra data, which might need further processing */
@ -1399,7 +1400,7 @@ static int reinterpret(const char *name, int namelen, int len,
int ret;
strbuf_add(buf, name + len, namelen - len);
ret = interpret_branch_name(buf->buf, buf->len, &tmp, allowed);
ret = repo_interpret_branch_name(r, buf->buf, buf->len, &tmp, allowed);
/* that data was not interpreted, remove our cruft */
if (ret < 0) {
strbuf_setlen(buf, used);
@ -1482,20 +1483,18 @@ int repo_interpret_branch_name(struct repository *r,
const char *start;
int len;
if (r != the_repository)
BUG("interpret_branch_name() does not really use 'r' yet");
if (!namelen)
namelen = strlen(name);
if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) {
len = interpret_nth_prior_checkout(the_repository, name, namelen, buf);
len = interpret_nth_prior_checkout(r, name, namelen, buf);
if (!len) {
return len; /* syntax Ok, not enough switches */
} else if (len > 0) {
if (len == namelen)
return len; /* consumed all */
else
return reinterpret(name, namelen, len, buf, allowed);
return reinterpret(r, name, namelen, len, buf, allowed);
}
}
@ -1506,17 +1505,17 @@ int repo_interpret_branch_name(struct repository *r,
if (!allowed || (allowed & INTERPRET_BRANCH_HEAD)) {
len = interpret_empty_at(name, namelen, at - name, buf);
if (len > 0)
return reinterpret(name, namelen, len, buf,
return reinterpret(r, name, namelen, len, buf,
allowed);
}
len = interpret_branch_mark(the_repository, name, namelen, at - name, buf,
len = interpret_branch_mark(r, name, namelen, at - name, buf,
upstream_mark, branch_get_upstream,
allowed);
if (len > 0)
return len;
len = interpret_branch_mark(the_repository, name, namelen, at - name, buf,
len = interpret_branch_mark(r, name, namelen, at - name, buf,
push_mark, branch_get_push,
allowed);
if (len > 0)