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