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>