提交 194db7e3 编写于 作者: J Junio C Hamano

Merge branch 'jc/for-each-ref' into jc/ref-locking

* jc/for-each-ref:
  git-for-each-ref: improve the documentation on scripting modes
...@@ -17,7 +17,7 @@ according to the given `<format>`, after sorting them according ...@@ -17,7 +17,7 @@ according to the given `<format>`, after sorting them according
to the given set of `<key>`s. If `<max>` is given, stop after to the given set of `<key>`s. If `<max>` is given, stop after
showing that many refs. The interporated values in `<format>` showing that many refs. The interporated values in `<format>`
can optionally be quoted as string literals in the specified can optionally be quoted as string literals in the specified
host language. host language allowing their direct evaluation in that language.
OPTIONS OPTIONS
------- -------
...@@ -97,7 +97,8 @@ returns an empty string instead. ...@@ -97,7 +97,8 @@ returns an empty string instead.
EXAMPLES EXAMPLES
-------- --------
Show the most recent 3 tagged commits:: An example directly producing formatted text. Show the most recent
3 tagged commits::
------------ ------------
#!/bin/sh #!/bin/sh
...@@ -112,7 +113,23 @@ Ref: %(*refname) ...@@ -112,7 +113,23 @@ Ref: %(*refname)
' 'refs/tags' ' '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 #!/bin/sh
...@@ -156,7 +173,7 @@ Its message reads as: ...@@ -156,7 +173,7 @@ Its message reads as:
fi fi
' '
eval=`git-for-each-ref -s --format="$fmt" \ eval=`git-for-each-ref --shell --format="$fmt" \
--sort='*objecttype' \ --sort='*objecttype' \
--sort=-taggerdate \ --sort=-taggerdate \
refs/tags` refs/tags`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册