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

Re: [RFC/PATCH 1/2] for-each-ref: add new format 'refbasename'

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Aug 29, 2008, 18:21 UTC
Message-ID
<36ca99e90808291121j7b202917r2308719970668be3@mail.gmail.com>
In-Reply-To
<0329f1ab2642e1dab701b5fc6517bfb1b4ea2d46.1220004755.git.szeder@ira.uka.de>
On Fri, Aug 29, 2008 at 12:37, SZEDER Gábor <szeder@ira.uka.de> wrote:
Show 9 quoted lines
> fot-each-ref's refname format outputs each ref in its full format, e.g.
> 'refs/heads/foo' and 'refs/tags/bar'.  However, there are tools that
> need only the last part of the refname, e.g. only 'foo' and 'bar'.  Such
> a tool is git's bash completion script, which spends considerable amount
> of time removing the unneeded parts from for-each-ref's output.
>
> Therefore, we introduce a new for-each-ref format called 'refbasename',
> which strips everything before and including the second '/' in the ref's
> name from the output.

Why not strip the pattern (given on the command line) from the refname? I.e. with a new format 'refshort' a 'git for-each-ref --format=%(refshort) refs/heads/' would strip off the refs/heads/ from each ref.

This should also work for multiple patterns (refs/heads/ refs/tags/) and for patterns which needs a fnmatch call (which has the FNM_PATHNAME option).

The bash completion script calls for-each-ref always with patterns.
Bert
Previous: SZEDER GáborNext: Bert Wesarg
Message 5 of 8 in “for-each-ref: add new format 'refbasename'”
  1. 1/2 for-each-ref: add new format 'refbasename'SZEDER Gábor, Aug 29, 2008
  2. 2/2 bash: use for-each-ref format 'refbasename'SZEDER Gábor, Aug 29, 2008
  3. Shawn O. PearceAug 29, 2008
  4. 1/2 for-each-ref: add new format 'refbasename'SZEDER Gábor, Aug 29, 2008
  5. Bert WesargAug 29, 2008
  6. for-each-ref: new 'refshort' formatBert Wesarg, Aug 29, 2008
  7. Junio C HamanoAug 31, 2008
  8. Bert WesargAug 31, 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.