git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] for-each-ref: `:short` format for `refname`

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Sep 2, 2008, 07:26 UTC
Message-ID
<36ca99e90809020026j37c41a8fu99b45abbd02eb372@mail.gmail.com>
In-Reply-To
<36ca99e90809011444v3fca09c4o4d9dcf1a7249a00a@mail.gmail.com>
On Mon, Sep 1, 2008 at 23:44, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 19 quoted lines
> On Mon, Sep 1, 2008 at 23:28, Junio C Hamano <gitster@pobox.com> wrote:
>> "Bert Wesarg" <bert.wesarg@googlemail.com> writes:
>>
>>> On Mon, Sep 1, 2008 at 21:10, Shawn O. Pearce <spearce@spearce.org> wrote:
>>> ...
>>>> You can still get ambiguous names.  Avoiding them requires going
>>>> through all refs and building their short forms, then using the
>>>> full ref name for any ref which had more than one name shorten to
>>>> the same string.  Ugly, but implementable, and probably something
>>>> that should be considered.
>>>
>>> What about: try the list backwards until the first match, than try the
>>> matched part (this what %.*s matched) with the forward list, if both
>>> give the same pattern, its not disambiguous. If not try the next
>>> pattern backwards.
>>
>> How does it catch the case where you have both 'xyzzy' branch and 'xyzzy'
>> tag, which is the point of disambiguation issue Shawn raised?
> Right.
I was wrong:
given these two refs:
  refs/heads/xyzzy
  refs/tags/xyzzy
first try to shorten "refs/heads/xyzzy":
  first (from the end) matched pattern is "refs/heads/%.*s" with
"xyzzy" as result
  but resolved ref for "xyzzy" is "refs/tags/xyzzy" => continue
  next matched pattern is "%.*s" with "refs/heads/xyzzy" as result
  end result is therefore: "refs/heads/xyzzy"
second try to shorten "refs/tags/xyzzy":
  first (from the end) matched pattern is "refs/tags/%.*s" with
"xyzzy" as result
  resolved ref for "xyzzy" is "refs/tags/xyzzy" => end
  end result is therefore: "xyzzy"
the output would be:
  refs/heads/xyzzy
  xyzzy

The question is now, if this is usable for bash completion? Current bash completion would handle this case wrong, because you get two xyzzy.

Bert
Previous: Bert WesargNext: Shawn O. Pearce
Message 9 of 26 in “for-each-ref: `:short` format for `refname`”
  1. for-each-ref: `:short` format for `refname`Bert Wesarg, Aug 31, 2008
  2. SZEDER GáborSep 1, 2008
  3. Bert WesargSep 1, 2008
  4. Bert WesargSep 1, 2008
  5. Shawn O. PearceSep 1, 2008
  6. Bert WesargSep 1, 2008
  7. Junio C HamanoSep 1, 2008
  8. Bert WesargSep 1, 2008
  9. Bert WesargSep 2, 2008
  10. Shawn O. PearceSep 2, 2008
  11. for-each-ref: `:short` format for `refname`Bert Wesarg, Sep 2, 2008
  12. Junio C HamanoSep 2, 2008
  13. Bert WesargSep 3, 2008
  14. for-each-ref: `:short` format for `refname`Bert Wesarg, Sep 3, 2008
  15. Shawn O. PearceSep 3, 2008
  16. Bert WesargSep 3, 2008
  17. Bert WesargSep 3, 2008
  18. Junio C HamanoSep 3, 2008
  19. for-each-ref: `:short` format for `refname`Bert Wesarg, Sep 5, 2008
  20. Junio C HamanoSep 5, 2008
  21. Bert WesargSep 6, 2008
  22. Junio C HamanoSep 8, 2008
  23. Shawn O. PearceSep 8, 2008
  24. Bert WesargSep 9, 2008
  25. Junio C HamanoSep 9, 2008
  26. Bert WesargSep 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.