Web lists-archives.org

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




On Fri, Aug 29, 2008 at 12:37, SZEDER Gábor <szeder@xxxxxxxxxx> wrote:
> 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