1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-for-each-ref(
1)
</title>
312 git-for-each-ref(
1) Manual Page
315 <div class=
"sectionbody">
316 <p>git-for-each-ref -
317 Output information on each ref
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git for-each-ref
</em> [--count=
<count
>] [--shell|--perl|--python|--tcl]
325 [--sort=
<key
>]* [--format=
<format
>] [
<pattern
>…]
</div></div>
327 <h2 id=
"_description">DESCRIPTION
</h2>
328 <div class=
"sectionbody">
329 <div class=
"para"><p>Iterate over all refs that match
<tt><pattern
></tt> and show them
330 according to the given
<tt><format
></tt>, after sorting them according
331 to the given set of
<tt><key
></tt>. If
<tt><count
></tt> is given, stop after
332 showing that many refs. The interpolated values in
<tt><format
></tt>
333 can optionally be quoted as string literals in the specified
334 host language allowing their direct evaluation in that language.
</p></div>
336 <h2 id=
"_options">OPTIONS
</h2>
337 <div class=
"sectionbody">
338 <div class=
"vlist"><dl>
344 By default the command shows all refs that match
345 <tt><pattern
></tt>. This option makes it stop after showing
354 A field name to sort on. Prefix
<tt>-
</tt> to sort in
355 descending order of the value. When unspecified,
356 <tt>refname
</tt> is used. You may use the --sort=
<key
> option
357 multiple times, in which case the last key becomes the primary
366 A string that interpolates
<tt>%(fieldname)
</tt> from the
367 object pointed at by a ref being shown. If
<tt>fieldname
</tt>
368 is prefixed with an asterisk (
<tt>*
</tt>) and the ref points
369 at a tag object, the value for the field in the object
370 tag refers is used. When unspecified, defaults to
371 <tt>%(objectname) SPC %(objecttype) TAB %(refname)
</tt>.
372 It also interpolates
<tt>%%
</tt> to
<tt>%
</tt>, and
<tt>%xx
</tt> where
<tt>xx
</tt>
373 are hex digits interpolates to character with hex code
374 <tt>xx
</tt>; for example
<tt>%
00</tt> interpolates to
<tt>\
0</tt> (NUL),
375 <tt>%
09</tt> to
<tt>\t
</tt> (TAB) and
<tt>%
0a
</tt> to
<tt>\n
</tt> (LF).
379 <pattern
>…
383 If one or more patterns are given, only refs are shown that
384 match against at least one pattern, either using fnmatch(
3) or
385 literally, in the latter case matching completely or from the
386 beginning up to a slash.
403 If given, strings that substitute
<tt>%(fieldname)
</tt>
404 placeholders are quoted as string literals suitable for
405 the specified host language. This is meant to produce
406 a scriptlet that can directly be `eval`ed.
411 <h2 id=
"_field_names">FIELD NAMES
</h2>
412 <div class=
"sectionbody">
413 <div class=
"para"><p>Various values from structured fields in referenced objects can
414 be used to interpolate into the resulting output, or as sort
416 <div class=
"para"><p>For all objects, the following names can be used:
</p></div>
417 <div class=
"vlist"><dl>
423 The name of the ref (the part after $GIT_DIR/).
424 For a non-ambiguous short name of the ref append
<tt>:short
</tt>.
425 The option core.warnAmbiguousRefs is used to select the strict
434 The type of the object (
<tt>blob
</tt>,
<tt>tree
</tt>,
<tt>commit
</tt>,
<tt>tag
</tt>).
442 The size of the object (the same as
<em>git-cat-file -s
</em> reports).
450 The object name (aka SHA-
1).
458 The name of a local ref which can be considered
“upstream
”
459 from the displayed ref. Respects
<tt>:short
</tt> in the same way as
460 <tt>refname
</tt> above.
464 <div class=
"para"><p>In addition to the above, for commit and tag objects, the header
465 field names (
<tt>tree
</tt>,
<tt>parent
</tt>,
<tt>object
</tt>,
<tt>type
</tt>, and
<tt>tag
</tt>) can
466 be used to specify the value in the header field.
</p></div>
467 <div class=
"para"><p>Fields that have name-email-date tuple as its value (
<tt>author
</tt>,
468 <tt>committer
</tt>, and
<tt>tagger
</tt>) can be suffixed with
<tt>name
</tt>,
<tt>email
</tt>,
469 and
<tt>date
</tt> to extract the named component.
</p></div>
470 <div class=
"para"><p>The first line of the message in a commit and tag object is
471 <tt>subject
</tt>, the remaining lines are
<tt>body
</tt>. The whole message
472 is
<tt>contents
</tt>.
</p></div>
473 <div class=
"para"><p>For sorting purposes, fields with numeric values sort in numeric
474 order (
<tt>objectsize
</tt>,
<tt>authordate
</tt>,
<tt>committerdate
</tt>,
<tt>taggerdate
</tt>).
475 All other fields are used to sort in their byte-value order.
</p></div>
476 <div class=
"para"><p>In any case, a field name that refers to a field inapplicable to
477 the object referred by the ref does not cause an error. It
478 returns an empty string instead.
</p></div>
479 <div class=
"para"><p>As a special case for the date-type fields, you may specify a format for
480 the date by adding one of
<tt>:default
</tt>,
<tt>:relative
</tt>,
<tt>:short
</tt>,
<tt>:local
</tt>,
481 <tt>:iso8601
</tt> or
<tt>:rfc2822
</tt> to the end of the fieldname; e.g.
482 <tt>%(taggerdate:relative)
</tt>.
</p></div>
484 <h2 id=
"_examples">EXAMPLES
</h2>
485 <div class=
"sectionbody">
486 <div class=
"para"><p>An example directly producing formatted text. Show the most recent
487 3 tagged commits::
</p></div>
488 <div class=
"listingblock">
489 <div class=
"content">
492 git for-each-ref --count=
3 --sort='-*authordate' \
493 --format='From: %(*authorname) %(*authoremail)
499 ' 'refs/tags'
</tt></pre>
501 <div class=
"para"><p>A simple example showing the use of shell eval on the output,
502 demonstrating the use of --shell. List the prefixes of all heads::
</p></div>
503 <div class=
"listingblock">
504 <div class=
"content">
507 git for-each-ref --shell
--format=
"ref=%(refname)" refs/heads | \
514 <div class=
"para"><p>A bit more elaborate report on tags, demonstrating that the format
515 may be an entire script::
</p></div>
516 <div class=
"listingblock">
517 <div class=
"content">
535 # could be a lightweight tag
537 kind=
"Lightweight tag"
545 echo
"$kind $T points at a $t object $o"
546 if test
"z$t" = zcommit
548 echo
"The commit was authored by $n $e
553 Its message reads as:
555 echo
"$b" | sed -e
"s/^/ /"
560 eval=`git for-each-ref --shell
--format=
"$fmt" \
561 --sort='*objecttype' \
564 eval
"$eval"</tt></pre>
568 <div id=
"footer-text">
569 Last updated
2009-
12-
03 09:
12:
35 UTC