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

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

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Sep 1, 2008, 13:15 UTC
Message-ID
<20080901131523.GA6739@neumann>
In-Reply-To
<1220186467-24623-1-git-send-email-bert.wesarg@googlemail.com>
Hi,
On Sun, Aug 31, 2008 at 02:41:07PM +0200, Bert Wesarg wrote:
Show 5 quoted lines
> This strips from the refname the common directory prefix with the
> matched pattern.
> 
> This is particular usefull for bash completion, to get refs without
> `refs/heads` or `refs/tags`.
Show 7 quoted lines
>  refname::
>  	The name of the ref (the part after $GIT_DIR/).
> +	For a short name of the ref append `:short`. This will strip
> +	the common directory prefix with the pattern which matches this ref.
> +	I.e. for a the pattern `refs/heads` you get `master`, or for
> +	`refs/tags/v1.5.[01].*` you get `v1.5.[01].*`.
> +	This is particular usefull for bash completion.
Should this last sentence really belong to the documentation?

Furthermore, I think ':strip' better describes what this format actually does. Even you have used the word 'strip' in the commit message and in the documentation as well.

As far as bash completion is concerned, I'm for it, as it does exactly what the completion script needs to perform better, it doesn't have those conceptual issues 'refbasename' has, and it's only a tad slower than 'refbasename'.

However, if we consider possible use cases other than bash completion, I don't know which one is more useful. For example, if you have two branches 'foo/bar' and 'foo/baz', then 'git merge $(git for-each-ref --format=%(refbasename) refs/heads/foo)' will work as expected, but 'refname:short' not, as it will output only 'bar' and 'baz' which 'git merge' can not find.

Best, Gábor

Previous: Bert WesargNext: Bert Wesarg
Message 2 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.