summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f613dd)
raw | patch | inline | side by side (parent: 9f613dd)
author | Andy Whitcroft <apw@shadowen.org> | |
Thu, 21 Sep 2006 09:19:17 +0000 (10:19 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 21 Sep 2006 19:38:38 +0000 (12:38 -0700) |
When reading the synopsis for git-for-each-ref it is easy to miss
the obvious power of --shell and family. Call this feature out in
the primary paragragh. Also add more description to the examples
to indicate which features we are demonstrating. Finally add a
very simple eval based example in addition to the very complex one
to give a gentler introduction.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
the obvious power of --shell and family. Call this feature out in
the primary paragragh. Also add more description to the examples
to indicate which features we are demonstrating. Finally add a
very simple eval based example in addition to the very complex one
to give a gentler introduction.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-for-each-ref.txt | patch | blob | history |
index 6649f795e8714d9f084a5f4db18bf3a1d405d46a..d5fdcef8d9e60d061ed83a8388ad1d3d0a47e6a5 100644 (file)
to the given set of `<key>`s. If `<max>` is given, stop after
showing that many refs. The interporated values in `<format>`
can optionally be quoted as string literals in the specified
-host language.
+host language allowing their direct evaluation in that language.
OPTIONS
-------
EXAMPLES
--------
-Show the most recent 3 tagged commits::
+An example directly producing formatted text. Show the most recent
+3 tagged commits::
------------
#!/bin/sh
' 'refs/tags'
------------
-A bit more elaborate report on tags::
+
+A simple example showing the use of shell eval on the output,
+demonstrating the use of --shell. List the prefixes of all heads::
+------------
+#!/bin/sh
+
+git-for-each-ref --shell --format="ref=%(refname)" refs/heads | \
+while read entry
+do
+ eval "$entry"
+ echo `dirname $ref`
+done
+------------
+
+
+A bit more elaborate report on tags, demonstrating that the format
+may be an entire script::
------------
#!/bin/sh
fi
'
-eval=`git-for-each-ref -s --format="$fmt" \
+eval=`git-for-each-ref --shell --format="$fmt" \
--sort='*objecttype' \
--sort=-taggerdate \
refs/tags`