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

Re: [PATCH 4/5] make get_short_ref a public function

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Apr 7, 2009, 07:39 UTC
Message-ID
<36ca99e90904070039m15869c34jc9e12d5ccc48d82@mail.gmail.com>
In-Reply-To
<20090407071420.GD2924@coredump.intra.peff.net>
On Tue, Apr 7, 2009 at 09:14, Jeff King <peff@peff.net> wrote:
Show 26 quoted lines
> Often we want to shorten a full ref name to something "prettier"
> to show a user. For example, "refs/heads/master" is often shown
> simply as "master", or "refs/remotes/origin/master" is shown as
> "origin/master".
>
> Many places in the code use a very simple formula: skip common
> prefixes like refs/heads, refs/remotes, etc. This is codified in
> the prettify_ref function.
>
> for-each-ref has a more correct (but more expensive) approach:
> consider the ref lookup rules, and try shortening as much as
> possible while remaining unambiguous.
>
> This patch makes the latter strategy globally available as
> shorten_unambiguous_ref.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> Actually, I am not quite sure that this function is "more correct". It
> looks at the rev-parsing rules as a hierarchy, so if you have
> "refs/remotes/foo" and "refs/heads/foo", then it will abbreviate the
> first to "remotes/foo" (as expected) and the latter to just "foo".
>
> This is technically correct, as "refs/heads/foo" will be selected by
> "foo", but it will warn about ambiguity. Should we actually try to avoid
> reporting refs which would be ambiguous?

Back than, there was the idea that the core.warnAmbiguousRefs config could be used for this.

Anyway
Acked-by: Bert Wesarg <bert.wesarg@googlemail.com>
Previous: Jeff KingNext: Jeff King
Message 8 of 24 in “making upstream branch information accessible”
  1. 0/5 making upstream branch information accessibleJeff King, Apr 7, 2009
  2. 1/5 for-each-ref: refactor get_short_ref functionJeff King, Apr 7, 2009
  3. 2/5 for-each-ref: refactor refname handlingJeff King, Apr 7, 2009
  4. Junio C HamanoApr 8, 2009
  5. Jeff KingApr 8, 2009
  6. 3/5 for-each-ref: add "upstream" format fieldJeff King, Apr 7, 2009
  7. 4/5 make get_short_ref a public functionJeff King, Apr 7, 2009
  8. Bert WesargApr 7, 2009
  9. Jeff KingApr 9, 2009
  10. Bert WesargApr 9, 2009
  11. Jeff KingApr 13, 2009
  12. Michael J GruberApr 7, 2009
  13. 5/5 branch: show upstream branch when double verboseJeff King, Apr 7, 2009
  14. Michael J GruberApr 7, 2009
  15. Jeff KingApr 9, 2009
  16. Santi BéjarApr 9, 2009
  17. Jeff KingApr 13, 2009
  18. Wincent ColaiutaApr 13, 2009
  19. Paolo CiarrocchiApr 7, 2009
  20. for-each-ref: remove multiple xstrdup() in get_short_ref()Bert Wesarg, Apr 7, 2009
  21. Jeff KingApr 7, 2009
  22. Bert WesargApr 7, 2009
  23. Jeff KingApr 7, 2009
  24. Bert WesargApr 7, 2009

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.