summaryrefslogtreecommitdiff
path: root/sha1-name.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-04-16 09:33:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-16 09:56:52 (GMT)
commit71588ed2c020b157a98882bc9e455841935cfcfa (patch)
tree9917ff4dcc9d8ae9647c3b88df34665bd60df92b /sha1-name.c
parentea1c873c7dd82353e7b42b5b9612946dac354142 (diff)
downloadgit-71588ed2c020b157a98882bc9e455841935cfcfa.zip
git-71588ed2c020b157a98882bc9e455841935cfcfa.tar.gz
git-71588ed2c020b157a98882bc9e455841935cfcfa.tar.bz2
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>
Diffstat (limited to 'sha1-name.c')
-rw-r--r--sha1-name.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sha1-name.c b/sha1-name.c
index 7d9512a..49c62d5 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -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)