summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-01-28 09:52:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-01-28 20:12:42 (GMT)
commitd46a8301930ae83de30fbbbbce1bb02a98745204 (patch)
treed58efd6ccd18ee97fc9e518c3d348f6920f0d901 /sha1_name.c
parent42cab601cfd0364c57434f90c6ba66a1ccb179ec (diff)
downloadgit-d46a8301930ae83de30fbbbbce1bb02a98745204.zip
git-d46a8301930ae83de30fbbbbce1bb02a98745204.tar.gz
git-d46a8301930ae83de30fbbbbce1bb02a98745204.tar.bz2
fix parsing of @{-1}@{u} combination
Previously interpret_branch_name would see @{-1} and stop parsing, leaving the @{u} as cruft that provoked an error. Instead, we should recurse if there is more to parse. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index c7f1510..00fc415 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -881,8 +881,28 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
if (!len)
return len; /* syntax Ok, not enough switches */
- if (0 < len)
- return len; /* consumed from the front */
+ if (0 < len && len == namelen)
+ return len; /* consumed all */
+ else if (0 < len) {
+ /* we have extra data, which might need further processing */
+ struct strbuf tmp = STRBUF_INIT;
+ int used = buf->len;
+ int ret;
+
+ strbuf_add(buf, name + len, namelen - len);
+ ret = interpret_branch_name(buf->buf, &tmp);
+ /* that data was not interpreted, remove our cruft */
+ if (ret < 0) {
+ strbuf_setlen(buf, used);
+ return len;
+ }
+ strbuf_reset(buf);
+ strbuf_addbuf(buf, &tmp);
+ strbuf_release(&tmp);
+ /* tweak for size of {-N} versus expanded ref name */
+ return ret - used + len;
+ }
+
cp = strchr(name, '@');
if (!cp)
return -1;