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;
check "@{-1}@{1}" old-one
check "@{u}" upstream-two
check "@{u}@{1}" upstream-one
-fail check "@{-1}@{u}" master-two
-fail check "@{-1}@{u}@{1}" master-one
+check "@{-1}@{u}" master-two
+check "@{-1}@{u}@{1}" master-one
fail nonsense "@{u}@{-1}"
nonsense "@{1}@{u}"