Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 65ad066d9b..93197b91e3 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1012,7 +1012,7 @@ static int reinterpret(const char *name, int namelen, int len, struct strbuf *bu
int ret;
strbuf_add(buf, name + len, namelen - len);
- ret = interpret_branch_name(buf->buf, &tmp);
+ ret = interpret_branch_name(buf->buf, buf->len, &tmp);
/* that data was not interpreted, remove our cruft */
if (ret < 0) {
strbuf_setlen(buf, used);
@@ -1046,14 +1046,16 @@ static int reinterpret(const char *name, int namelen, int len, struct strbuf *bu
* If the input was ok but there are not N branch switches in the
* reflog, it returns 0.
*/
-int interpret_branch_name(const char *name, struct strbuf *buf)
+int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
{
char *cp;
struct branch *upstream;
- int namelen = strlen(name);
int len = interpret_nth_prior_checkout(name, buf);
int tmp_len;
+ if (!namelen)
+ namelen = strlen(name);
+
if (!len) {
return len; /* syntax Ok, not enough switches */
} else if (len > 0) {
@@ -1100,7 +1102,7 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
int strbuf_branchname(struct strbuf *sb, const char *name)
{
int len = strlen(name);
- int used = interpret_branch_name(name, sb);
+ int used = interpret_branch_name(name, len, sb);
if (used == len)
return 0;