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

Re: [PATCH] tag: do not show ambiguous tag names as "tags/foo"

From
Jeff King <peff@peff.net>
Date
Jan 24, 2016, 22:27 UTC
Message-ID
<20160124222736.GA29115@sigill.intra.peff.net>
In-Reply-To
<xmqqvb6iboxj.fsf@gitster.mtv.corp.google.com>
On Sun, Jan 24, 2016 at 02:19:52PM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> >> Instead, let's extend the "short" modifier in the formatting
> >> language to handle a specific prefix. This fixes "git tag",
> >> and lets users invoke the same behavior from their own
> >> custom formats (for "tag" or "for-each-ref") while leaving
> >> ":short" with its same consistent meaning in all places.
> 
> Yeah, I do agree with the analysis.
> 
> I however wonder if short=$prefix is a good end-user interface,
> though, as strip=$prefix may be more intuitive to them, I suspect.

Yeah, I picked "short" just because of the existing feature. But we are not bound to use the same name at all, and "strip" is probably more descriptive (I thought "prefix" might also be, but that only communicates what it _is_, not that we are removing it).

> Also there is "what happens if the expected prefix is not there?"
> question.

I think "do not strip anything" (as I have here) is an OK behavior. It would not come up for sane requests (i.e., you would generally be filtering to match your prefix anyway).

But...
Show 8 quoted lines
> Perhaps strip=2 can be defined to "strip 2 levels of
> hierarchy prefix no matter what that is", and strip refs/tags/foo,
> refs/heads/foo and refs/remotes/origin/foo to foo, foo, origin/foo,
> respectively?  The filtering natively done by the listing mode of
> "branch" and "tags" would ensure the prefixes are always what we
> implicitly expect, so the case we need to worry about how we should
> signal errors becomes "what if there are not enough levels".  That
> may be simpler to handle.

Yeah, "strip=2" would also get the job done, and extends more naturally to the branch case.

To be honest, I cannot imagine anybody using anything _but_ strip=2, but maybe there are special cases, like:

  git for-each-ref --format='%(refname:strip=3)' refs/heads/jk/
to get my list of topics, sans initials.

I had originally hoped to avoid exposing any of this to the user, and just make things internal, so that we would not be locked into a particular formatting behavior. But since we now have "tag --format" and advertise "%(refname:short)" as its default, I think it has become user-visible.

Let me see what the "strip=X" patch looks like.
-Peff
Previous: Junio C HamanoNext: Eric Sunshine
Message 5 of 19 in “Regression? Ambiguous tags listed as "tags/<foo>"”
  1. Pete HarlanJan 23, 2016
  2. tag: do not show ambiguous tag names as "tags/foo"Jeff King, Jan 24, 2016
  3. Jeff KingJan 24, 2016
  4. Junio C HamanoJan 24, 2016
  5. Jeff KingJan 24, 2016
  6. Eric SunshineJan 24, 2016
  7. Jeff KingJan 25, 2016
  8. Junio C HamanoJan 25, 2016
  9. Jeff KingJan 25, 2016
  10. Karthik NayakJan 25, 2016
  11. Junio C HamanoJan 25, 2016
  12. Jeff KingJan 26, 2016
  13. Jeff KingJan 26, 2016
  14. Junio C HamanoJan 26, 2016
  15. Jeff KingJan 24, 2016
  16. 1/2 t6300: use test_atom for some un-modern testsJeff King, Jan 24, 2016
  17. 2/2 tag: do not show ambiguous tag names as "tags/foo"Jeff King, Jan 24, 2016
  18. Junio C HamanoJan 26, 2016
  19. Karthik NayakJan 26, 2016

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.