diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-05-08 14:05:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-08 14:05:15 -0700 |
commit | 2f6355a9313e03f152df60c65eeb2662269969d9 (patch) | |
tree | 1d0816cd3cb278012e730b0a9b33f9e349fd3b50 | |
parent | c7ef70c7676fb404d2b0745963def5fa15366345 (diff) | |
download | git-jc/more-robust-nth-prior-checkout.tar.gz |
interpret_branch_name(): unconfuse @{-1}@{u} when @{-1} is detachedjc/more-robust-nth-prior-checkout
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 <gitster@pobox.com>
-rw-r--r-- | sha1_name.c | 12 |
1 files 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; |