From 2f6355a9313e03f152df60c65eeb2662269969d9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 8 May 2013 14:05:15 -0700 Subject: interpret_branch_name(): unconfuse @{-1}@{u} when @{-1} is detached Now interpret_nth_prior_checkout() can tell the caller if the result of expansion of @{-1} is a real branch name or the commit object name for a detached HEAD state, let's avoid re-interpreting $HEX@{u} in the latter case. Signed-off-by: Junio C Hamano --- sha1_name.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 1473bb61bb..d3b68978be 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1004,15 +1004,21 @@ int interpret_branch_name(const char *name, struct strbuf *buf) char *cp; struct branch *upstream; int namelen = strlen(name); - int len = interpret_nth_prior_checkout(name, buf, NULL); + int detached; + int len = interpret_nth_prior_checkout(name, buf, &detached); int tmp_len; if (!len) return len; /* syntax Ok, not enough switches */ if (0 < len && len == namelen) return len; /* consumed all */ - else if (0 < len) { - /* we have extra data, which might need further processing */ + else if (0 < len && !detached) { + /* + * We have extra data, which might need further + * processing. E.g. for the original "@{-1}@{u}" we + * have converted @{-1} into buf and yet to process + * the remaining @{u} part. + */ struct strbuf tmp = STRBUF_INIT; int used = buf->len; int ret; -- cgit v1.2.1